元编程参考文档

Keras 模型

6 个节点

本页内容 6

构建 Keras 模型

函数

Makes a model of the layers between an input and an output.

签名
构建 Keras 模型 -> Keras Model
    输入: KerasTensor
    输出: KerasTensor
    名称: 文本
KerasModel BuildKerasModel(
    KerasTensor input,
    KerasTensor output,
    string name)

参数

名称类型默认值说明
输入KerasTensor—The Input the network starts from.
输出KerasTensor—The last layer's tensor.
名称文本—A name for the model; empty for Keras's own.

返回

模型Keras Model
所属发行版
元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
Keras 模型
所属包
机器学习

加载 Keras 模型

函数

Loads a model saved in Keras's .keras format, by this package or by Python's Keras.

签名
加载 Keras 模型(路径: 文本) -> Keras Model
KerasModel LoadKerasModel(string path)

参数

名称类型默认值说明
路径文本—The .keras file.

返回

模型Keras Model
所属发行版
元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
Keras 模型
所属包
机器学习

预测单个样本

函数

The model's answer for one example.

签名
预测单个样本(模型: Keras Model, 特征: 数字数组) -> 数字数组
double[] PredictOne(KerasModel model, double[] features)

参数

名称类型默认值说明
模型Keras Model—A trained model.
特征数字数组—The example's numbers, in the order it was trained on.

返回

输出数字数组
所属发行版
元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
Keras 模型
所属包
机器学习

用 Keras 模型预测

函数

The model's answers for the rows of a table, as a table with one column per output.

签名
用 Keras 模型预测 -> Table
    模型: Keras Model
    数据: Table
    特征: 文本数组
Table PredictWithKerasModel(
    KerasModel model,
    Table data,
    string[] features)

参数

名称类型默认值说明
模型Keras Model—A trained model.
数据Table—The rows.
特征文本数组—The columns it sees, in the order it was trained on.

返回

预测结果Table
所属发行版
元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
Keras 模型
所属包
机器学习

保存 Keras 模型

函数

Saves a model in Keras's .keras format: its layers, weights and training setup in one file.

签名
保存 Keras 模型(模型: Keras Model, 路径: 文本) -> 文本
string SaveKerasModel(KerasModel model, string path)

参数

名称类型默认值说明
模型Keras Model—The model.
路径文本—The file to write, ending in .keras.

返回

路径文本
所属发行版
元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
Keras 模型
所属包
机器学习

训练 Keras 模型

函数

Trains a model on the rows of a table: some columns are what it sees, others what it should answer.

签名
训练 Keras 模型 -> (模型: Keras Model, 损失: 数字数组, 验证损失: 数字数组)
    模型: Keras Model
    数据: Table
    特征: 文本数组
    标签: 文本数组
    损失: 文本
    优化器: 文本
    学习率: 数字
    轮数: 整数
    批大小: 整数
    验证比例: 数字
    种子: 整数
KerasModel TrainKerasModel(
    KerasModel model,
    Table data,
    string[] features,
    string[] labels,
    string loss,
    string optimizer,
    double learningRate,
    int epochs,
    int batchSize,
    double validationShare,
    int seed,
    out double[] losses,
    out double[] validationLosses)

参数

名称类型默认值说明
模型Keras Model—The model; training changes it.
数据Table—The training rows.
特征文本数组—The columns it sees, in the order of its input.
标签文本数组—The columns it should answer. For sparse_categorical_crossentropy, one column of class numbers 0, 1, 2...
损失文本—What it minimizes: mse or mae for numbers, binary_crossentropy for yes or no, sparse_categorical_crossentropy for one of several classes.
优化器文本—adam, sgd, rmsprop, adamw...
学习率数字—How big each step is.
轮数整数—How many times to go through the data.
批大小整数—How many rows each step sees.
验证比例数字—The share of rows, taken from the end, kept back to measure the model on rows it has not trained on; 0 for none.
种子整数—Makes the run repeatable: the starting weights, the shuffling and dropout.

返回

模型Keras Model
损失数字数组
验证损失数字数组
所属发行版
元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
Keras 模型
所属包
机器学习