Type RNNModel
Namespace tensorflow_estimator.python.estimator.canned.rnn
Parent Model
Interfaces IRNNModel
Methods
- add_loss
- add_loss
- add_loss
- add_loss
- add_loss
- add_loss_dyn
- add_metric
- add_metric
- add_metric
- add_metric_dyn
- add_update
- add_update
- add_update
- add_update_dyn
- add_weight
- add_weight
- add_weight
- add_weight
- call
- call
- call
- call
- call
- call
- call_dyn
- compile
- compile
- compile
- compile
- compile
- compile
- compile
- compile
- compile
- compile
- compile
- compile
- compile
- compile_dyn
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- evaluate
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit
- fit_generator
- from_config_dyn<TClass>
- from_config<TClass>
- get_config
- get_config_dyn
- get_updates_for
- get_updates_for
- get_updates_for
- get_updates_for_dyn
- get_weights__dyn
- load_weights
- load_weights
- load_weights
- load_weights_dyn
- NewDyn
- predict_on_batch
- predict_on_batch
- predict_on_batch
- predict_on_batch_dyn
- save_dyn
- save_weights
- save_weights
- save_weights_dyn
- set_weights_
- set_weights__dyn
- summary
- summary_dyn
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch
- test_on_batch_dyn
- to_json
- to_json_dyn
- to_yaml
- to_yaml_dyn
Properties
- activity_regularizer
- activity_regularizer_dyn
- built
- dtype
- dtype_dyn
- dynamic
- dynamic_dyn
- inbound_nodes
- inbound_nodes_dyn
- input
- input_dyn
- input_mask
- input_mask_dyn
- input_names
- input_shape
- input_shape_dyn
- input_spec
- input_spec_dyn
- inputs
- layers
- layers_dyn
- loss
- loss_functions
- loss_weights
- losses
- losses_dyn
- metrics
- metrics_dyn
- metrics_names
- metrics_names_dyn
- name
- name_dyn
- name_scope
- name_scope_dyn
- non_trainable_variables
- non_trainable_variables_dyn
- non_trainable_weights
- non_trainable_weights_dyn
- optimizer
- outbound_nodes
- outbound_nodes_dyn
- output
- output_dyn
- output_mask
- output_mask_dyn
- output_names
- output_shape
- output_shape_dyn
- outputs
- predict_function
- PythonObject
- run_eagerly
- run_eagerly_dyn
- sample_weight_mode
- sample_weights
- sample_weights_dyn
- state_updates
- state_updates_dyn
- stateful
- stateful_dyn
- submodules
- submodules_dyn
- supports_masking
- test_function
- total_loss
- train_function
- trainable
- trainable_dyn
- trainable_variables
- trainable_variables_dyn
- trainable_weights
- trainable_weights_dyn
- updates
- updates_dyn
- variables
- variables_dyn
- weights
- weights_dyn
Public instance methods
void add_loss(object losses, bool inputs)
Add loss tensor(s), potentially dependent on layer inputs. Some losses (for instance, activity regularization losses) may be dependent
on the inputs passed when calling a layer. Hence, when reusing the same
layer on different inputs `a` and `b`, some entries in `layer.losses` may
be dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. This method can be used inside a subclassed layer or model's `call`
function, in which case `losses` should be a Tensor or list of Tensors. Example:
This method can also be called directly on a Functional Model during
construction. In this case, any loss Tensors passed to this Model must
be symbolic and be able to be traced back to the model's `Input`s. These
losses become part of the model's topology and are tracked in `get_config`. Example:
If this is not the case for your loss (if, for example, your loss references
a `Variable` of one of the model's layers), you can wrap your loss in a
zero-argument lambda. These losses are not tracked as part of the model's
topology since they can't be serialized. Example:
The `get_losses_for` method allows to retrieve the losses relevant to a
specific set of inputs.
Parameters
-
object
losses - Loss tensor, or list/tuple of tensors. Rather than tensors, losses may also be zero-argument callables which create a loss tensor.
-
bool
inputs - Ignored when executing eagerly. If anything other than None is passed, it signals the losses are conditional on some of the layer's inputs, and thus they should only be run where these inputs are available. This is the case for activity regularization losses, for instance. If `None` is passed, the losses are assumed to be unconditional, and will apply across all dataflows of the layer (e.g. weight regularization losses).
Show Example
class MyLayer(tf.keras.layers.Layer): def call(inputs, self): self.add_loss(tf.abs(tf.reduce_mean(inputs)), inputs=True) return inputs
void add_loss(object losses, IEnumerable<IGraphNodeBase> inputs)
Add loss tensor(s), potentially dependent on layer inputs. Some losses (for instance, activity regularization losses) may be dependent
on the inputs passed when calling a layer. Hence, when reusing the same
layer on different inputs `a` and `b`, some entries in `layer.losses` may
be dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. This method can be used inside a subclassed layer or model's `call`
function, in which case `losses` should be a Tensor or list of Tensors. Example:
This method can also be called directly on a Functional Model during
construction. In this case, any loss Tensors passed to this Model must
be symbolic and be able to be traced back to the model's `Input`s. These
losses become part of the model's topology and are tracked in `get_config`. Example:
If this is not the case for your loss (if, for example, your loss references
a `Variable` of one of the model's layers), you can wrap your loss in a
zero-argument lambda. These losses are not tracked as part of the model's
topology since they can't be serialized. Example:
The `get_losses_for` method allows to retrieve the losses relevant to a
specific set of inputs.
Parameters
-
object
losses - Loss tensor, or list/tuple of tensors. Rather than tensors, losses may also be zero-argument callables which create a loss tensor.
-
IEnumerable<IGraphNodeBase>
inputs - Ignored when executing eagerly. If anything other than None is passed, it signals the losses are conditional on some of the layer's inputs, and thus they should only be run where these inputs are available. This is the case for activity regularization losses, for instance. If `None` is passed, the losses are assumed to be unconditional, and will apply across all dataflows of the layer (e.g. weight regularization losses).
Show Example
class MyLayer(tf.keras.layers.Layer): def call(inputs, self): self.add_loss(tf.abs(tf.reduce_mean(inputs)), inputs=True) return inputs
void add_loss(PythonFunctionContainer losses, IEnumerable<IGraphNodeBase> inputs)
Add loss tensor(s), potentially dependent on layer inputs. Some losses (for instance, activity regularization losses) may be dependent
on the inputs passed when calling a layer. Hence, when reusing the same
layer on different inputs `a` and `b`, some entries in `layer.losses` may
be dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. This method can be used inside a subclassed layer or model's `call`
function, in which case `losses` should be a Tensor or list of Tensors. Example:
This method can also be called directly on a Functional Model during
construction. In this case, any loss Tensors passed to this Model must
be symbolic and be able to be traced back to the model's `Input`s. These
losses become part of the model's topology and are tracked in `get_config`. Example:
If this is not the case for your loss (if, for example, your loss references
a `Variable` of one of the model's layers), you can wrap your loss in a
zero-argument lambda. These losses are not tracked as part of the model's
topology since they can't be serialized. Example:
The `get_losses_for` method allows to retrieve the losses relevant to a
specific set of inputs.
Parameters
-
PythonFunctionContainer
losses - Loss tensor, or list/tuple of tensors. Rather than tensors, losses may also be zero-argument callables which create a loss tensor.
-
IEnumerable<IGraphNodeBase>
inputs - Ignored when executing eagerly. If anything other than None is passed, it signals the losses are conditional on some of the layer's inputs, and thus they should only be run where these inputs are available. This is the case for activity regularization losses, for instance. If `None` is passed, the losses are assumed to be unconditional, and will apply across all dataflows of the layer (e.g. weight regularization losses).
Show Example
class MyLayer(tf.keras.layers.Layer): def call(inputs, self): self.add_loss(tf.abs(tf.reduce_mean(inputs)), inputs=True) return inputs
void add_loss(object losses, IGraphNodeBase inputs)
Add loss tensor(s), potentially dependent on layer inputs. Some losses (for instance, activity regularization losses) may be dependent
on the inputs passed when calling a layer. Hence, when reusing the same
layer on different inputs `a` and `b`, some entries in `layer.losses` may
be dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. This method can be used inside a subclassed layer or model's `call`
function, in which case `losses` should be a Tensor or list of Tensors. Example:
This method can also be called directly on a Functional Model during
construction. In this case, any loss Tensors passed to this Model must
be symbolic and be able to be traced back to the model's `Input`s. These
losses become part of the model's topology and are tracked in `get_config`. Example:
If this is not the case for your loss (if, for example, your loss references
a `Variable` of one of the model's layers), you can wrap your loss in a
zero-argument lambda. These losses are not tracked as part of the model's
topology since they can't be serialized. Example:
The `get_losses_for` method allows to retrieve the losses relevant to a
specific set of inputs.
Parameters
-
object
losses - Loss tensor, or list/tuple of tensors. Rather than tensors, losses may also be zero-argument callables which create a loss tensor.
-
IGraphNodeBase
inputs - Ignored when executing eagerly. If anything other than None is passed, it signals the losses are conditional on some of the layer's inputs, and thus they should only be run where these inputs are available. This is the case for activity regularization losses, for instance. If `None` is passed, the losses are assumed to be unconditional, and will apply across all dataflows of the layer (e.g. weight regularization losses).
Show Example
class MyLayer(tf.keras.layers.Layer): def call(inputs, self): self.add_loss(tf.abs(tf.reduce_mean(inputs)), inputs=True) return inputs
void add_loss(PythonFunctionContainer losses, IGraphNodeBase inputs)
Add loss tensor(s), potentially dependent on layer inputs. Some losses (for instance, activity regularization losses) may be dependent
on the inputs passed when calling a layer. Hence, when reusing the same
layer on different inputs `a` and `b`, some entries in `layer.losses` may
be dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. This method can be used inside a subclassed layer or model's `call`
function, in which case `losses` should be a Tensor or list of Tensors. Example:
This method can also be called directly on a Functional Model during
construction. In this case, any loss Tensors passed to this Model must
be symbolic and be able to be traced back to the model's `Input`s. These
losses become part of the model's topology and are tracked in `get_config`. Example:
If this is not the case for your loss (if, for example, your loss references
a `Variable` of one of the model's layers), you can wrap your loss in a
zero-argument lambda. These losses are not tracked as part of the model's
topology since they can't be serialized. Example:
The `get_losses_for` method allows to retrieve the losses relevant to a
specific set of inputs.
Parameters
-
PythonFunctionContainer
losses - Loss tensor, or list/tuple of tensors. Rather than tensors, losses may also be zero-argument callables which create a loss tensor.
-
IGraphNodeBase
inputs - Ignored when executing eagerly. If anything other than None is passed, it signals the losses are conditional on some of the layer's inputs, and thus they should only be run where these inputs are available. This is the case for activity regularization losses, for instance. If `None` is passed, the losses are assumed to be unconditional, and will apply across all dataflows of the layer (e.g. weight regularization losses).
Show Example
class MyLayer(tf.keras.layers.Layer): def call(inputs, self): self.add_loss(tf.abs(tf.reduce_mean(inputs)), inputs=True) return inputs
object add_loss_dyn(object losses, object inputs)
Add loss tensor(s), potentially dependent on layer inputs. Some losses (for instance, activity regularization losses) may be dependent
on the inputs passed when calling a layer. Hence, when reusing the same
layer on different inputs `a` and `b`, some entries in `layer.losses` may
be dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. This method can be used inside a subclassed layer or model's `call`
function, in which case `losses` should be a Tensor or list of Tensors. Example:
This method can also be called directly on a Functional Model during
construction. In this case, any loss Tensors passed to this Model must
be symbolic and be able to be traced back to the model's `Input`s. These
losses become part of the model's topology and are tracked in `get_config`. Example:
If this is not the case for your loss (if, for example, your loss references
a `Variable` of one of the model's layers), you can wrap your loss in a
zero-argument lambda. These losses are not tracked as part of the model's
topology since they can't be serialized. Example:
The `get_losses_for` method allows to retrieve the losses relevant to a
specific set of inputs.
Parameters
-
object
losses - Loss tensor, or list/tuple of tensors. Rather than tensors, losses may also be zero-argument callables which create a loss tensor.
-
object
inputs - Ignored when executing eagerly. If anything other than None is passed, it signals the losses are conditional on some of the layer's inputs, and thus they should only be run where these inputs are available. This is the case for activity regularization losses, for instance. If `None` is passed, the losses are assumed to be unconditional, and will apply across all dataflows of the layer (e.g. weight regularization losses).
Show Example
class MyLayer(tf.keras.layers.Layer): def call(inputs, self): self.add_loss(tf.abs(tf.reduce_mean(inputs)), inputs=True) return inputs
void add_metric(IGraphNodeBase value, string aggregation, string name)
Adds metric tensor to the layer.
Parameters
-
IGraphNodeBase
value - Metric tensor.
-
string
aggregation - Sample-wise metric reduction function. If `aggregation=None`, it indicates that the metric tensor provided has been aggregated already. eg, `bin_acc = BinaryAccuracy(name='acc')` followed by `model.add_metric(bin_acc(y_true, y_pred))`. If aggregation='mean', the given metric tensor will be sample-wise reduced using `mean` function. eg, `model.add_metric(tf.reduce_sum(outputs), name='output_mean', aggregation='mean')`.
-
string
name - String metric name.
void add_metric(IEnumerable<IGraphNodeBase> value, string aggregation, string name)
Adds metric tensor to the layer.
Parameters
-
IEnumerable<IGraphNodeBase>
value - Metric tensor.
-
string
aggregation - Sample-wise metric reduction function. If `aggregation=None`, it indicates that the metric tensor provided has been aggregated already. eg, `bin_acc = BinaryAccuracy(name='acc')` followed by `model.add_metric(bin_acc(y_true, y_pred))`. If aggregation='mean', the given metric tensor will be sample-wise reduced using `mean` function. eg, `model.add_metric(tf.reduce_sum(outputs), name='output_mean', aggregation='mean')`.
-
string
name - String metric name.
void add_metric(double value, string aggregation, string name)
Adds metric tensor to the layer.
Parameters
-
double
value - Metric tensor.
-
string
aggregation - Sample-wise metric reduction function. If `aggregation=None`, it indicates that the metric tensor provided has been aggregated already. eg, `bin_acc = BinaryAccuracy(name='acc')` followed by `model.add_metric(bin_acc(y_true, y_pred))`. If aggregation='mean', the given metric tensor will be sample-wise reduced using `mean` function. eg, `model.add_metric(tf.reduce_sum(outputs), name='output_mean', aggregation='mean')`.
-
string
name - String metric name.
object add_metric_dyn(object value, object aggregation, object name)
Adds metric tensor to the layer.
Parameters
-
object
value - Metric tensor.
-
object
aggregation - Sample-wise metric reduction function. If `aggregation=None`, it indicates that the metric tensor provided has been aggregated already. eg, `bin_acc = BinaryAccuracy(name='acc')` followed by `model.add_metric(bin_acc(y_true, y_pred))`. If aggregation='mean', the given metric tensor will be sample-wise reduced using `mean` function. eg, `model.add_metric(tf.reduce_sum(outputs), name='output_mean', aggregation='mean')`.
-
object
name - String metric name.
void add_update(IEnumerable<object> updates, Nullable<bool> inputs)
Add update op(s), potentially dependent on layer inputs. (deprecated arguments) Warning: SOME ARGUMENTS ARE DEPRECATED: `(inputs)`. They will be removed in a future version.
Instructions for updating:
`inputs` is now automatically inferred Weight updates (for instance, the updates of the moving mean and variance
in a BatchNormalization layer) may be dependent on the inputs passed
when calling a layer. Hence, when reusing the same layer on
different inputs `a` and `b`, some entries in `layer.updates` may be
dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. The `get_updates_for` method allows to retrieve the updates relevant to a
specific set of inputs. This call is ignored when eager execution is enabled (in that case, variable
updates are run on the fly and thus do not need to be tracked for later
execution).
Parameters
-
IEnumerable<object>
updates - Update op, or list/tuple of update ops, or zero-arg callable that returns an update op. A zero-arg callable should be passed in order to disable running the updates by setting `trainable=False` on this Layer, when executing in Eager mode.
-
Nullable<bool>
inputs - Deprecated, will be automatically inferred.
void add_update(IGraphNodeBase updates, Nullable<bool> inputs)
Add update op(s), potentially dependent on layer inputs. (deprecated arguments) Warning: SOME ARGUMENTS ARE DEPRECATED: `(inputs)`. They will be removed in a future version.
Instructions for updating:
`inputs` is now automatically inferred Weight updates (for instance, the updates of the moving mean and variance
in a BatchNormalization layer) may be dependent on the inputs passed
when calling a layer. Hence, when reusing the same layer on
different inputs `a` and `b`, some entries in `layer.updates` may be
dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. The `get_updates_for` method allows to retrieve the updates relevant to a
specific set of inputs. This call is ignored when eager execution is enabled (in that case, variable
updates are run on the fly and thus do not need to be tracked for later
execution).
Parameters
-
IGraphNodeBase
updates - Update op, or list/tuple of update ops, or zero-arg callable that returns an update op. A zero-arg callable should be passed in order to disable running the updates by setting `trainable=False` on this Layer, when executing in Eager mode.
-
Nullable<bool>
inputs - Deprecated, will be automatically inferred.
void add_update(object updates, Nullable<bool> inputs)
Add update op(s), potentially dependent on layer inputs. (deprecated arguments) Warning: SOME ARGUMENTS ARE DEPRECATED: `(inputs)`. They will be removed in a future version.
Instructions for updating:
`inputs` is now automatically inferred Weight updates (for instance, the updates of the moving mean and variance
in a BatchNormalization layer) may be dependent on the inputs passed
when calling a layer. Hence, when reusing the same layer on
different inputs `a` and `b`, some entries in `layer.updates` may be
dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. The `get_updates_for` method allows to retrieve the updates relevant to a
specific set of inputs. This call is ignored when eager execution is enabled (in that case, variable
updates are run on the fly and thus do not need to be tracked for later
execution).
Parameters
-
object
updates - Update op, or list/tuple of update ops, or zero-arg callable that returns an update op. A zero-arg callable should be passed in order to disable running the updates by setting `trainable=False` on this Layer, when executing in Eager mode.
-
Nullable<bool>
inputs - Deprecated, will be automatically inferred.
object add_update_dyn(object updates, object inputs)
Add update op(s), potentially dependent on layer inputs. (deprecated arguments) Warning: SOME ARGUMENTS ARE DEPRECATED: `(inputs)`. They will be removed in a future version.
Instructions for updating:
`inputs` is now automatically inferred Weight updates (for instance, the updates of the moving mean and variance
in a BatchNormalization layer) may be dependent on the inputs passed
when calling a layer. Hence, when reusing the same layer on
different inputs `a` and `b`, some entries in `layer.updates` may be
dependent on `a` and some on `b`. This method automatically keeps track
of dependencies. The `get_updates_for` method allows to retrieve the updates relevant to a
specific set of inputs. This call is ignored when eager execution is enabled (in that case, variable
updates are run on the fly and thus do not need to be tracked for later
execution).
Parameters
-
object
updates - Update op, or list/tuple of update ops, or zero-arg callable that returns an update op. A zero-arg callable should be passed in order to disable running the updates by setting `trainable=False` on this Layer, when executing in Eager mode.
-
object
inputs - Deprecated, will be automatically inferred.
object add_weight(string name, IEnumerable<int> shape, DType dtype, object initializer, object regularizer, object trainable, object constraint, object partitioner, object use_resource, ImplicitContainer<T> synchronization, ImplicitContainer<T> aggregation, IDictionary<string, object> kwargs)
Adds a new variable to the layer.
Parameters
-
string
name - Variable name.
-
IEnumerable<int>
shape - Variable shape. Defaults to scalar if unspecified.
-
DType
dtype - The type of the variable. Defaults to `self.dtype` or `float32`.
-
object
initializer - Initializer instance (callable).
-
object
regularizer - Regularizer instance (callable).
-
object
trainable - Boolean, whether the variable should be part of the layer's "trainable_variables" (e.g. variables, biases) or "non_trainable_variables" (e.g. BatchNorm mean and variance). Note that `trainable` cannot be `True` if `synchronization` is set to `ON_READ`.
-
object
constraint - Constraint instance (callable).
-
object
partitioner - Partitioner to be passed to the `Trackable` API.
-
object
use_resource - Whether to use `ResourceVariable`.
-
ImplicitContainer<T>
synchronization - Indicates when a distributed a variable will be
aggregated. Accepted values are constants defined in the class
tf.VariableSynchronization
. By default the synchronization is set to `AUTO` and the current `DistributionStrategy` chooses when to synchronize. If `synchronization` is set to `ON_READ`, `trainable` must not be set to `True`. -
ImplicitContainer<T>
aggregation - Indicates how a distributed variable will be aggregated.
Accepted values are constants defined in the class
tf.VariableAggregation
. -
IDictionary<string, object>
kwargs - Additional keyword arguments. Accepted values are `getter` and `collections`.
Returns
-
object
- The created variable. Usually either a `Variable` or `ResourceVariable` instance. If `partitioner` is not `None`, a `PartitionedVariable` instance is returned.
object add_weight(string name, IEnumerable<int> shape, DType dtype, object initializer, object regularizer, object trainable, IDictionary<object, object> constraint, object partitioner, object use_resource, ImplicitContainer<T> synchronization, ImplicitContainer<T> aggregation, IDictionary<string, object> kwargs)
Adds a new variable to the layer.
Parameters
-
string
name - Variable name.
-
IEnumerable<int>
shape - Variable shape. Defaults to scalar if unspecified.
-
DType
dtype - The type of the variable. Defaults to `self.dtype` or `float32`.
-
object
initializer - Initializer instance (callable).
-
object
regularizer - Regularizer instance (callable).
-
object
trainable - Boolean, whether the variable should be part of the layer's "trainable_variables" (e.g. variables, biases) or "non_trainable_variables" (e.g. BatchNorm mean and variance). Note that `trainable` cannot be `True` if `synchronization` is set to `ON_READ`.
-
IDictionary<object, object>
constraint - Constraint instance (callable).
-
object
partitioner - Partitioner to be passed to the `Trackable` API.
-
object
use_resource - Whether to use `ResourceVariable`.
-
ImplicitContainer<T>
synchronization - Indicates when a distributed a variable will be
aggregated. Accepted values are constants defined in the class
tf.VariableSynchronization
. By default the synchronization is set to `AUTO` and the current `DistributionStrategy` chooses when to synchronize. If `synchronization` is set to `ON_READ`, `trainable` must not be set to `True`. -
ImplicitContainer<T>
aggregation - Indicates how a distributed variable will be aggregated.
Accepted values are constants defined in the class
tf.VariableAggregation
. -
IDictionary<string, object>
kwargs - Additional keyword arguments. Accepted values are `getter` and `collections`.
Returns
-
object
- The created variable. Usually either a `Variable` or `ResourceVariable` instance. If `partitioner` is not `None`, a `PartitionedVariable` instance is returned.
object add_weight(string name, IEnumerable<int> shape, DType dtype, PythonClassContainer initializer, object regularizer, object trainable, object constraint, object partitioner, object use_resource, ImplicitContainer<T> synchronization, ImplicitContainer<T> aggregation, IDictionary<string, object> kwargs)
Adds a new variable to the layer.
Parameters
-
string
name - Variable name.
-
IEnumerable<int>
shape - Variable shape. Defaults to scalar if unspecified.
-
DType
dtype - The type of the variable. Defaults to `self.dtype` or `float32`.
-
PythonClassContainer
initializer - Initializer instance (callable).
-
object
regularizer - Regularizer instance (callable).
-
object
trainable - Boolean, whether the variable should be part of the layer's "trainable_variables" (e.g. variables, biases) or "non_trainable_variables" (e.g. BatchNorm mean and variance). Note that `trainable` cannot be `True` if `synchronization` is set to `ON_READ`.
-
object
constraint - Constraint instance (callable).
-
object
partitioner - Partitioner to be passed to the `Trackable` API.
-
object
use_resource - Whether to use `ResourceVariable`.
-
ImplicitContainer<T>
synchronization - Indicates when a distributed a variable will be
aggregated. Accepted values are constants defined in the class
tf.VariableSynchronization
. By default the synchronization is set to `AUTO` and the current `DistributionStrategy` chooses when to synchronize. If `synchronization` is set to `ON_READ`, `trainable` must not be set to `True`. -
ImplicitContainer<T>
aggregation - Indicates how a distributed variable will be aggregated.
Accepted values are constants defined in the class
tf.VariableAggregation
. -
IDictionary<string, object>
kwargs - Additional keyword arguments. Accepted values are `getter` and `collections`.
Returns
-
object
- The created variable. Usually either a `Variable` or `ResourceVariable` instance. If `partitioner` is not `None`, a `PartitionedVariable` instance is returned.
object add_weight(string name, IEnumerable<int> shape, DType dtype, PythonClassContainer initializer, object regularizer, object trainable, IDictionary<object, object> constraint, object partitioner, object use_resource, ImplicitContainer<T> synchronization, ImplicitContainer<T> aggregation, IDictionary<string, object> kwargs)
Adds a new variable to the layer.
Parameters
-
string
name - Variable name.
-
IEnumerable<int>
shape - Variable shape. Defaults to scalar if unspecified.
-
DType
dtype - The type of the variable. Defaults to `self.dtype` or `float32`.
-
PythonClassContainer
initializer - Initializer instance (callable).
-
object
regularizer - Regularizer instance (callable).
-
object
trainable - Boolean, whether the variable should be part of the layer's "trainable_variables" (e.g. variables, biases) or "non_trainable_variables" (e.g. BatchNorm mean and variance). Note that `trainable` cannot be `True` if `synchronization` is set to `ON_READ`.
-
IDictionary<object, object>
constraint - Constraint instance (callable).
-
object
partitioner - Partitioner to be passed to the `Trackable` API.
-
object
use_resource - Whether to use `ResourceVariable`.
-
ImplicitContainer<T>
synchronization - Indicates when a distributed a variable will be
aggregated. Accepted values are constants defined in the class
tf.VariableSynchronization
. By default the synchronization is set to `AUTO` and the current `DistributionStrategy` chooses when to synchronize. If `synchronization` is set to `ON_READ`, `trainable` must not be set to `True`. -
ImplicitContainer<T>
aggregation - Indicates how a distributed variable will be aggregated.
Accepted values are constants defined in the class
tf.VariableAggregation
. -
IDictionary<string, object>
kwargs - Additional keyword arguments. Accepted values are `getter` and `collections`.
Returns
-
object
- The created variable. Usually either a `Variable` or `ResourceVariable` instance. If `partitioner` is not `None`, a `PartitionedVariable` instance is returned.
Tensor call(IEnumerable<IGraphNodeBase> inputs, IDictionary<string, object> kwargs)
This is where the layer's logic lives.
Parameters
-
IEnumerable<IGraphNodeBase>
inputs - Input tensor, or list/tuple of input tensors.
-
IDictionary<string, object>
kwargs - Additional keyword arguments.
Returns
-
Tensor
- A tensor or list/tuple of tensors.
Tensor call(IGraphNodeBase inputs, IDictionary<string, object> kwargs)
This is where the layer's logic lives.
Parameters
-
IGraphNodeBase
inputs - Input tensor, or list/tuple of input tensors.
-
IDictionary<string, object>
kwargs - Additional keyword arguments.
Returns
-
Tensor
- A tensor or list/tuple of tensors.
Tensor call(IGraphNodeBase inputs, IGraphNodeBase training)
Tensor call(IGraphNodeBase inputs, bool training)
Tensor call(IEnumerable<IGraphNodeBase> inputs, IGraphNodeBase training)
Tensor call(IEnumerable<IGraphNodeBase> inputs, bool training)
object call_dyn(object inputs, IDictionary<string, object> kwargs)
This is where the layer's logic lives.
Parameters
-
object
inputs - Input tensor, or list/tuple of input tensors.
-
IDictionary<string, object>
kwargs - Additional keyword arguments.
Returns
-
object
- A tensor or list/tuple of tensors.
void compile(ImplicitContainer<T> optimizer, object loss, CategoricalAccuracy metrics, IEnumerable<double> loss_weights, string sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
CategoricalAccuracy
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IEnumerable<double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
string
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, CategoricalAccuracy metrics, IEnumerable<double> loss_weights, IEnumerable<object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
CategoricalAccuracy
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IEnumerable<double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IEnumerable<object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, IEnumerable<object> metrics, IEnumerable<double> loss_weights, IDictionary<string, object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
IEnumerable<object>
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IEnumerable<double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IDictionary<string, object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, CategoricalAccuracy metrics, IDictionary<string, double> loss_weights, string sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
CategoricalAccuracy
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IDictionary<string, double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
string
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, PythonFunctionContainer loss, IEnumerable<object> metrics, IEnumerable<double> loss_weights, IDictionary<string, object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
PythonFunctionContainer
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
IEnumerable<object>
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IEnumerable<double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IDictionary<string, object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, IEnumerable<object> metrics, IEnumerable<double> loss_weights, IEnumerable<object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
IEnumerable<object>
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IEnumerable<double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IEnumerable<object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, PythonFunctionContainer loss, IEnumerable<object> metrics, IDictionary<string, double> loss_weights, string sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
PythonFunctionContainer
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
IEnumerable<object>
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IDictionary<string, double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
string
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, CategoricalAccuracy metrics, IDictionary<string, double> loss_weights, IEnumerable<object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
CategoricalAccuracy
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IDictionary<string, double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IEnumerable<object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, IEnumerable<object> metrics, IEnumerable<double> loss_weights, string sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
IEnumerable<object>
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IEnumerable<double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
string
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, PythonFunctionContainer loss, IEnumerable<object> metrics, IDictionary<string, double> loss_weights, IEnumerable<object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
PythonFunctionContainer
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
IEnumerable<object>
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IDictionary<string, double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IEnumerable<object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, CategoricalAccuracy metrics, IDictionary<string, double> loss_weights, IDictionary<string, object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
CategoricalAccuracy
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IDictionary<string, double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IDictionary<string, object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, object loss, CategoricalAccuracy metrics, IEnumerable<double> loss_weights, IDictionary<string, object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
CategoricalAccuracy
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IEnumerable<double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IDictionary<string, object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
void compile(ImplicitContainer<T> optimizer, PythonFunctionContainer loss, IEnumerable<object> metrics, IDictionary<string, double> loss_weights, IDictionary<string, object> sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
PythonFunctionContainer
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
IEnumerable<object>
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
IDictionary<string, double>
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
IDictionary<string, object>
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
object compile_dyn(ImplicitContainer<T> optimizer, object loss, object metrics, object loss_weights, object sample_weight_mode, object weighted_metrics, object target_tensors, object distribute, IDictionary<string, object> kwargs)
Configures the model for training.
Parameters
-
ImplicitContainer<T>
optimizer - String (name of optimizer) or optimizer instance.
See
tf.keras.optimizers
. -
object
loss - String (name of objective function), objective function or
`tf.losses.Loss` instance. See
tf.losses
. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses. -
object
metrics - 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, such as `metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}`. You can also pass a list (len = len(outputs)) of lists of metrics such as `metrics=[['accuracy'], ['accuracy', 'mse']]` or `metrics=['accuracy', ['accuracy', 'mse']]`.
-
object
loss_weights - Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the *weighted sum* of all individual losses, weighted by the `loss_weights` coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a tensor, it is expected to map output names (strings) to scalar coefficients.
-
object
sample_weight_mode - If you need to do timestep-wise sample weighting (2D weights), set this to `"temporal"`. `None` defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different `sample_weight_mode` on each output by passing a dictionary or a list of modes.
-
object
weighted_metrics - List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
-
object
target_tensors - By default, Keras will create placeholders for the model's target, which will be fed with the target data during training. If instead you would like to use your own target tensors (in turn, Keras will not expect external Numpy data for these targets at training time), you can specify them via the `target_tensors` argument. It can be a single tensor (for a single-output model), a list of tensors, or a dict mapping output names to target tensors.
-
object
distribute - NOT SUPPORTED IN TF 2.0, please create and compile the model under distribution strategy scope instead of passing it to compile.
-
IDictionary<string, object>
kwargs - Any additional arguments.
object evaluate(object x, int y, Nullable<int> batch_size, bool verbose, IDictionary<string, object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
int
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, IGraphNodeBase y, Nullable<int> batch_size, int verbose, ndarray sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
ndarray
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, IGraphNodeBase y, Nullable<int> batch_size, bool verbose, IEnumerable<object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, IGraphNodeBase y, Nullable<int> batch_size, bool verbose, IDictionary<string, object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, IGraphNodeBase y, Nullable<int> batch_size, bool verbose, ndarray sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
ndarray
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, int y, Nullable<int> batch_size, int verbose, IEnumerable<object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
int
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, int y, Nullable<int> batch_size, int verbose, IDictionary<string, object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
int
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, int y, Nullable<int> batch_size, int verbose, ndarray sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
int
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
ndarray
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, int y, Nullable<int> batch_size, bool verbose, ndarray sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
int
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
ndarray
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, int y, Nullable<int> batch_size, bool verbose, IEnumerable<object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
int
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, HDF5Matrix y, Nullable<int> batch_size, int verbose, IDictionary<string, object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
HDF5Matrix
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, HDF5Matrix y, Nullable<int> batch_size, int verbose, ndarray sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
HDF5Matrix
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
ndarray
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, HDF5Matrix y, Nullable<int> batch_size, int verbose, IEnumerable<object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
HDF5Matrix
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, HDF5Matrix y, Nullable<int> batch_size, bool verbose, IEnumerable<object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
HDF5Matrix
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, HDF5Matrix y, Nullable<int> batch_size, bool verbose, IDictionary<string, object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
HDF5Matrix
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, HDF5Matrix y, Nullable<int> batch_size, bool verbose, ndarray sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
HDF5Matrix
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
bool
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
ndarray
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object evaluate(object x, IEnumerable<object> y, Nullable<int> batch_size, int verbose, IEnumerable<object> sample_weight, Nullable<int> steps, IEnumerable<Callback> callbacks, int max_queue_size, int workers, bool use_multiprocessing)
Returns the loss value & metrics values for the model in test mode. Computation is done in batches.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. - A generator or `keras.utils.Sequence` instance. -
IEnumerable<object>
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from the iterator/dataset).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` is your data is in the form of symbolic tensors, dataset, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
verbose - 0 or 1. Verbosity mode. 0 = silent, 1 = progress bar.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the test samples, used for weighting the loss function. You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, instead pass sample weights as the third element of `x`.
-
Nullable<int>
steps - Integer or `None`.
Total number of steps (batches of samples)
before declaring the evaluation round finished.
Ignored with the default value of `None`.
If x is a
tf.data
dataset and `steps` is None, 'evaluate' will run until the dataset is exhausted. This argument is not supported with array inputs. -
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances. List of callbacks to apply during evaluation. See [callbacks](/api_docs/python/tf/keras/callbacks).
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, bool shuffle, IDictionary<string, string> class_weight, IEnumerable<object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, string shuffle, IDictionary<string, string> class_weight, ndarray sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
string
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
ndarray
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, string shuffle, IDictionary<string, string> class_weight, IDictionary<string, object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
string
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, string shuffle, IDictionary<string, string> class_weight, IEnumerable<object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
string
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, bool shuffle, IDictionary<string, string> class_weight, ndarray sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
ndarray
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, bool shuffle, IDictionary<string, string> class_weight, IDictionary<string, object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, bool shuffle, IDictionary<string, string> class_weight, IEnumerable<object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, string shuffle, IDictionary<string, string> class_weight, IEnumerable<object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
string
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, bool shuffle, IDictionary<string, string> class_weight, ndarray sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
ndarray
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, bool shuffle, IDictionary<string, string> class_weight, IEnumerable<object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, string shuffle, IDictionary<string, string> class_weight, ndarray sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
string
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
ndarray
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, string shuffle, IDictionary<string, string> class_weight, IDictionary<string, object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
string
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, Dataset validation_data, string shuffle, IDictionary<string, string> class_weight, IEnumerable<object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
Dataset
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
string
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IEnumerable<object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, bool shuffle, IDictionary<string, string> class_weight, ndarray sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
ndarray
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, bool verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, bool shuffle, IDictionary<string, string> class_weight, IDictionary<string, object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
bool
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, int verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, bool shuffle, IDictionary<string, string> class_weight, IDictionary<string, object> sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
int
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
IDictionary<string, object>
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit(object x, object y, Nullable<int> batch_size, int epochs, int verbose, IEnumerable<Callback> callbacks, double validation_split, ValueTuple<IEnumerable<object>, object> validation_data, bool shuffle, IDictionary<string, string> class_weight, ndarray sample_weight, int initial_epoch, Nullable<int> steps_per_epoch, Nullable<int> validation_steps, int validation_freq, int max_queue_size, int workers, bool use_multiprocessing, IDictionary<string, object> kwargs)
Trains the model for a fixed number of epochs (iterations on a dataset).
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. Should return a tuple of either `(inputs, targets)` or `(inputs, targets, sample_weights)`. - A generator or `keras.utils.Sequence` returning `(inputs, targets)` or `(inputs, targets, sample weights)`. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset, generator, or `keras.utils.Sequence` instance, `y` should not be specified (since targets will be obtained from `x`).
-
Nullable<int>
batch_size - Integer or `None`. Number of samples per gradient update. If unspecified, `batch_size` will default to 32. Do not specify the `batch_size` if your data is in the form of symbolic tensors, datasets, generators, or `keras.utils.Sequence` instances (since they generate batches).
-
int
epochs - Integer. Number of epochs to train the model. An epoch is an iteration over the entire `x` and `y` data provided. Note that in conjunction with `initial_epoch`, `epochs` is to be understood as "final epoch". The model is not trained for a number of iterations given by `epochs`, but merely until the epoch of index `epochs` is reached.
-
int
verbose - 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar, 2 = one line per epoch. Note that the progress bar is not particularly useful when logged to a file, so verbose=2 is recommended when not running interactively (eg, in a production environment).
-
IEnumerable<Callback>
callbacks - List of `keras.callbacks.Callback` instances.
List of callbacks to apply during training.
See
tf.keras.callbacks
. -
double
validation_split - Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the `x` and `y` data provided, before shuffling. This argument is not supported when `x` is a dataset, generator or `keras.utils.Sequence` instance.
-
ValueTuple<IEnumerable<object>, object>
validation_data - Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. `validation_data` will override `validation_split`. `validation_data` could be: - tuple `(x_val, y_val)` of Numpy arrays or tensors - tuple `(x_val, y_val, val_sample_weights)` of Numpy arrays - dataset For the first two cases, `batch_size` must be provided. For the last case, `validation_steps` must be provided.
-
bool
shuffle - Boolean (whether to shuffle the training data before each epoch) or str (for 'batch'). 'batch' is a special option for dealing with the limitations of HDF5 data; it shuffles in batch-sized chunks. Has no effect when `steps_per_epoch` is not `None`.
-
IDictionary<string, string>
class_weight - Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.
-
ndarray
sample_weight - Optional Numpy array of weights for the training samples, used for weighting the loss function (during training only). You can either pass a flat (1D) Numpy array with the same length as the input samples (1:1 mapping between weights and samples), or in the case of temporal data, you can pass a 2D array with shape `(samples, sequence_length)`, to apply a different weight to every timestep of every sample. In this case you should make sure to specify `sample_weight_mode="temporal"` in `compile()`. This argument is not supported when `x` is a dataset, generator, or `keras.utils.Sequence` instance, instead provide the sample_weights as the third element of `x`.
-
int
initial_epoch - Integer. Epoch at which to start training (useful for resuming a previous training run).
-
Nullable<int>
steps_per_epoch - Integer or `None`.
Total number of steps (batches of samples)
before declaring one epoch finished and starting the
next epoch. When training with input tensors such as
TensorFlow data tensors, the default `None` is equal to
the number of samples in your dataset divided by
the batch size, or 1 if that cannot be determined. If x is a
tf.data
dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. This argument is not supported with array inputs. -
Nullable<int>
validation_steps - Only relevant if `validation_data` is provided and
is a
tf.data
dataset. Total number of steps (batches of samples) to draw before stopping when performing validation at the end of every epoch. If validation_data is atf.data
dataset and 'validation_steps' is None, validation will run until the `validation_data` dataset is exhausted. -
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
int
max_queue_size - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Used for generator or `keras.utils.Sequence` input only. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. Used for generator or `keras.utils.Sequence` input only. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
IDictionary<string, object>
kwargs - Used for backwards compatibility.
Returns
-
object
- A `History` object. Its `History.history` attribute is a record of training loss values and metrics values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
object fit_generator(IEnumerator<ValueTuple<IEnumerable<object>, object>> generator, Nullable<int> steps_per_epoch, int epochs, int verbose, IEnumerable<object> callbacks, IEnumerator<ValueTuple<object, object>> validation_data, Nullable<int> validation_steps, int validation_freq, IDictionary<string, object> class_weight, int max_queue_size, int workers, bool use_multiprocessing, bool shuffle, int initial_epoch)
Fits the model on data yielded batch-by-batch by a Python generator. The generator is run in parallel to the model, for efficiency.
For instance, this allows you to do real-time data augmentation
on images on CPU in parallel to training your model on GPU. The use of `keras.utils.Sequence` guarantees the ordering
and guarantees the single use of every input per epoch when
using `use_multiprocessing=True`.
Parameters
-
IEnumerator<ValueTuple<IEnumerable<object>, object>>
generator - A generator or an instance of `Sequence` (`keras.utils.Sequence`) object in order to avoid duplicate data when using multiprocessing. The output of the generator must be either - a tuple `(inputs, targets)` - a tuple `(inputs, targets, sample_weights)`. This tuple (a single output of the generator) makes a single batch. Therefore, all arrays in this tuple must have the same length (equal to the size of this batch). Different batches may have different sizes. For example, the last batch of the epoch is commonly smaller than the others, if the size of the dataset is not divisible by the batch size. The generator is expected to loop over its data indefinitely. An epoch finishes when `steps_per_epoch` batches have been seen by the model.
-
Nullable<int>
steps_per_epoch - Total number of steps (batches of samples) to yield from `generator` before declaring one epoch finished and starting the next epoch. It should typically be equal to the number of samples of your dataset divided by the batch size. Optional for `Sequence`: if unspecified, will use the `len(generator)` as a number of steps.
-
int
epochs - Integer, total number of iterations on the data.
-
int
verbose - Verbosity mode, 0, 1, or 2.
-
IEnumerable<object>
callbacks - List of callbacks to be called during training.
-
IEnumerator<ValueTuple<object, object>>
validation_data - This can be either - a generator for the validation data - a tuple (inputs, targets) - a tuple (inputs, targets, sample_weights).
-
Nullable<int>
validation_steps - Only relevant if `validation_data` is a generator. Total number of steps (batches of samples) to yield from `generator` before stopping. Optional for `Sequence`: if unspecified, will use the `len(validation_data)` as a number of steps.
-
int
validation_freq - Only relevant if validation data is provided. Integer or `collections_abc.Container` instance (e.g. list, tuple, etc.). If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. `validation_freq=2` runs validation every 2 epochs. If a Container, specifies the epochs on which to run validation, e.g. `validation_freq=[1, 2, 10]` runs validation at the end of the 1st, 2nd, and 10th epochs.
-
IDictionary<string, object>
class_weight - Dictionary mapping class indices to a weight for the class.
-
int
max_queue_size - Integer. Maximum size for the generator queue. If unspecified, `max_queue_size` will default to 10.
-
int
workers - Integer. Maximum number of processes to spin up when using process-based threading. If unspecified, `workers` will default to 1. If 0, will execute the generator on the main thread.
-
bool
use_multiprocessing - Boolean. If `True`, use process-based threading. If unspecified, `use_multiprocessing` will default to `False`. Note that because this implementation relies on multiprocessing, you should not pass non-picklable arguments to the generator as they can't be passed easily to children processes.
-
bool
shuffle - Boolean. Whether to shuffle the order of the batches at the beginning of each epoch. Only used with instances of `Sequence` (`keras.utils.Sequence`). Has no effect when `steps_per_epoch` is not `None`.
-
int
initial_epoch - Epoch at which to start training (useful for resuming a previous training run)
Returns
-
object
- A `History` object. Example: ```python def generate_arrays_from_file(path): while 1: f = open(path) for line in f: # create numpy arrays of input data # and labels, from each line in the file x1, x2, y = process_line(line) yield ({'input_1': x1, 'input_2': x2}, {'output': y}) f.close() model.fit_generator(generate_arrays_from_file('/my_file.txt'), steps_per_epoch=10000, epochs=10) ```
IDictionary<string, object> get_config()
Returns the config of this loss scale.
object get_config_dyn()
Returns the config of this loss scale.
IList<Tensor> get_updates_for(IGraphNodeBase inputs)
Retrieves updates relevant to a specific set of inputs.
Parameters
-
IGraphNodeBase
inputs - Input tensor or list/tuple of input tensors.
Returns
-
IList<Tensor>
- List of update ops of the layer that depend on `inputs`.
IList<Tensor> get_updates_for(IDictionary<object, object> inputs)
Retrieves updates relevant to a specific set of inputs.
Parameters
-
IDictionary<object, object>
inputs - Input tensor or list/tuple of input tensors.
Returns
-
IList<Tensor>
- List of update ops of the layer that depend on `inputs`.
IList<Tensor> get_updates_for(IEnumerable<object> inputs)
Retrieves updates relevant to a specific set of inputs.
Parameters
-
IEnumerable<object>
inputs - Input tensor or list/tuple of input tensors.
Returns
-
IList<Tensor>
- List of update ops of the layer that depend on `inputs`.
object get_updates_for_dyn(object inputs)
Retrieves updates relevant to a specific set of inputs.
Parameters
-
object
inputs - Input tensor or list/tuple of input tensors.
Returns
-
object
- List of update ops of the layer that depend on `inputs`.
object get_weights__dyn()
object load_weights(IGraphNodeBase filepath, bool by_name)
Loads all layer weights, either from a TensorFlow or an HDF5 file.
object load_weights(string filepath, bool by_name)
Loads all layer weights, either from a TensorFlow or an HDF5 file.
object load_weights(Byte[] filepath, bool by_name)
Loads all layer weights, either from a TensorFlow or an HDF5 file.
object load_weights_dyn(object filepath, ImplicitContainer<T> by_name)
Loads all layer weights, either from a TensorFlow or an HDF5 file.
object predict_on_batch(IDictionary<string, object> x)
Returns predictions for a single batch of samples.
Parameters
-
IDictionary<string, object>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A
tf.data
dataset.
Returns
-
object
- Numpy array(s) of predictions.
object predict_on_batch(IEnumerable<object> x)
Returns predictions for a single batch of samples.
Parameters
-
IEnumerable<object>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A
tf.data
dataset.
Returns
-
object
- Numpy array(s) of predictions.
object predict_on_batch(ndarray x)
Returns predictions for a single batch of samples.
Parameters
Returns
-
object
- Numpy array(s) of predictions.
object predict_on_batch_dyn(object x)
Returns predictions for a single batch of samples.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A
tf.data
dataset.
Returns
-
object
- Numpy array(s) of predictions.
object save_dyn(object filepath, ImplicitContainer<T> overwrite, ImplicitContainer<T> include_optimizer, object save_format, object signatures)
object save_weights(Byte[] filepath, bool overwrite, string save_format)
object save_weights(string filepath, bool overwrite, string save_format)
object save_weights_dyn(object filepath, ImplicitContainer<T> overwrite, object save_format)
void set_weights_(IEnumerable<object> weights)
object set_weights__dyn(object weights)
void summary(object line_length, object positions, PythonFunctionContainer print_fn)
object summary_dyn(object line_length, object positions, object print_fn)
object test_on_batch(IGraphNodeBase x, IGraphNodeBase y, IDictionary<string, object> sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IGraphNodeBase
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
IDictionary<string, object>
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IGraphNodeBase x, IGraphNodeBase y, ndarray sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IGraphNodeBase
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
ndarray
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IGraphNodeBase x, IEnumerable<object> y, IDictionary<string, object> sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IGraphNodeBase
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IEnumerable<object>
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
IDictionary<string, object>
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IGraphNodeBase x, IEnumerable<object> y, ndarray sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IGraphNodeBase
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IEnumerable<object>
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
ndarray
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IEnumerable<IGraphNodeBase> x, ndarray y, ndarray sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IEnumerable<IGraphNodeBase>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
ndarray
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
ndarray
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IEnumerable<IGraphNodeBase> x, ndarray y, IDictionary<string, object> sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IEnumerable<IGraphNodeBase>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
ndarray
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
IDictionary<string, object>
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IEnumerable<IGraphNodeBase> x, IEnumerable<object> y, ndarray sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IEnumerable<IGraphNodeBase>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IEnumerable<object>
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
ndarray
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IGraphNodeBase x, ndarray y, ndarray sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IGraphNodeBase
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
ndarray
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
ndarray
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IEnumerable<IGraphNodeBase> x, IEnumerable<object> y, IDictionary<string, object> sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IEnumerable<IGraphNodeBase>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IEnumerable<object>
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
IDictionary<string, object>
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IEnumerable<IGraphNodeBase> x, IGraphNodeBase y, ndarray sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IEnumerable<IGraphNodeBase>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
ndarray
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IEnumerable<IGraphNodeBase> x, IGraphNodeBase y, IDictionary<string, object> sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IEnumerable<IGraphNodeBase>
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
IGraphNodeBase
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
IDictionary<string, object>
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch(IGraphNodeBase x, ndarray y, IDictionary<string, object> sample_weight, bool reset_metrics)
Test the model on a single batch of samples.
Parameters
-
IGraphNodeBase
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
ndarray
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
IDictionary<string, object>
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
bool
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
object test_on_batch_dyn(object x, object y, object sample_weight, ImplicitContainer<T> reset_metrics)
Test the model on a single batch of samples.
Parameters
-
object
x - Input data. It could be:
- A Numpy array (or array-like), or a list of arrays
(in case the model has multiple inputs).
- A TensorFlow tensor, or a list of tensors
(in case the model has multiple inputs).
- A dict mapping input names to the corresponding array/tensors,
if the model has named inputs.
- A
tf.data
dataset. -
object
y - Target data. Like the input data `x`, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with `x` (you cannot have Numpy inputs and tensor targets, or inversely). If `x` is a dataset `y` should not be specified (since targets will be obtained from the iterator).
-
object
sample_weight - Optional array of the same length as x, containing weights to apply to the model's loss for each sample. In the case of temporal data, you can pass a 2D array with shape (samples, sequence_length), to apply a different weight to every timestep of every sample. In this case you should make sure to specify sample_weight_mode="temporal" in compile(). This argument is not supported when `x` is a dataset.
-
ImplicitContainer<T>
reset_metrics - If `True`, the metrics returned will be only for this batch. If `False`, the metrics will be statefully accumulated across batches.
Returns
-
object
- Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute `model.metrics_names` will give you the display labels for the scalar outputs.
string to_json(IDictionary<string, object> kwargs)
object to_json_dyn(IDictionary<string, object> kwargs)
object to_yaml(IDictionary<string, object> kwargs)
object to_yaml_dyn(IDictionary<string, object> kwargs)
Public static methods
object from_config_dyn<TClass>(object config, object custom_objects)
Creates an optimizer from its config. This method is the reverse of `get_config`,
capable of instantiating the same optimizer from the config
dictionary.
Parameters
-
object
config - A Python dictionary, typically the output of get_config.
-
object
custom_objects - A Python dictionary mapping names to additional Python objects used to create this optimizer, such as a function used for a hyperparameter.
Returns
-
object
- An optimizer instance.
TClass from_config<TClass>(IDictionary<object, object> config, IDictionary<object, object> custom_objects)
Creates an optimizer from its config. This method is the reverse of `get_config`,
capable of instantiating the same optimizer from the config
dictionary.
Parameters
-
IDictionary<object, object>
config - A Python dictionary, typically the output of get_config.
-
IDictionary<object, object>
custom_objects - A Python dictionary mapping names to additional Python objects used to create this optimizer, such as a function used for a hyperparameter.
Returns
-
TClass
- An optimizer instance.