Methods
# inner add(model, layer) → {Void}
Adds a layer instance on top of the layer stack.
Parameters:
Name | Type | Description |
---|---|---|
model |
SequentialModel
|
Sequential model to add layer on. |
layer |
Layer
|
Layer instance. |
model.add(layer)
Void
# inner compile(model, optimizer, loss, metrics) → {Void}
Configures and prepares the model for training and evaluation.
Parameters:
Name | Type | Description |
---|---|---|
model |
LayersModel
|
The model compile. |
optimizer |
String
|
An instance of tf.train.Optimizer or a string name for an Optimizer. |
loss |
String
|
Array.<String>
|
(string|string[]|{[outputName: string]: string}|LossOrMetricFn| LossOrMetricFn[]|{[outputName: string]: LossOrMetricFn}) Object function(s) or name(s) of object function(s). If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or an Array of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. |
metrics |
String
|
(string|LossOrMetricFn|Array| {[outputName: string]: string | LossOrMetricFn}) List of metrics to be evaluated by the model during training and testing. Typically you will use metrics=['accuracy']. To specify different metrics for different outputs of a multi-output model, you could also pass a dictionary. |
model.compile({optimizer, loss, metrics})
Void
# inner fit(model, x, y, epochs, batchSize) → {Promise}
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters:
Name | Type | Description |
---|---|---|
model |
LayersModel
|
The model compile. |
x |
Tensor
|
An tf.Tensor of training data, or an array of tf.Tensors if the model has multiple inputs. If all inputs in the model are named, you can also pass a dictionary mapping input names to tf.Tensors. |
y |
Tensor
|
tf.Tensor of target (label) data, or an array of tf.Tensors if the model has multiple outputs. If all outputs in the model are named, you can also pass a dictionary mapping output names to tf.Tensors. |
epochs |
Number
|
Integer number of times to iterate over the training data arrays. |
batchSize |
Number
|
Number of samples per gradient update. If unspecified, it will default to 32. |
await model.fit(xs, ys, {epochs, batchSize})
Promise
# inner predict(model, tensor) → {Tensor}
Execute the inference for the input tensors.
Parameters:
Name | Type | Description |
---|---|---|
model |
LayersModel
|
The model compile. |
tensor |
Tensor
|
The input data, as a Tensor, or an Array of tf.Tensors if the model has multiple inputs. |
model.predict(tensor)
Tensor