platypush/plugins/tensorflow/__init__.py
def create_network(self,
                       name: str,
                       layers: List[Union[Layer, Dict[str, Any]]],
                       input_names: Optional[List[str]] = None,
                       output_names: Optional[List[str]] = None,
                       optimizer: Optional[str] = 'rmsprop',
                       loss: Optional[Union[str, List[str], Dict[str, str]]] = None,
                       metrics: Optional[
                           Union[str, List[Union[str, List[str]]], Dict[str, Union[str, List[str]]]]] = None,
                       loss_weights: Optional[Union[List[float], Dict[str, float]]] = None,
                       sample_weight_mode: Optional[Union[str, List[str], Dict[str, str]]] = None,
                       weighted_metrics: Optional[List[str]] = None,
                       target_tensors=None,
                       **kwargs) -> Dict[str, Any]:
        """
        Create a neural network TensorFlow Keras model.

        :param name: Name of the model.
        :param layers: List of layers. Example:

          .. code-block:: javascript

            [
              // Input flatten layer with 10 units
              {
                "type": "Flatten",
                "input_shape": [10, 10]
              },

              // Dense hidden layer with 500 units
              {
                "type": "Dense",
                "units": 500,
                "activation": "relu"
              },

              // Dense hidden layer with 100 units
              {
                "type": "Dense",
                "units": 100,
                "activation": "relu"
              },

              // Dense output layer with 2 units (labels) and ``softmax`` activation function
              {
                "type": "Dense",
                "units": 2,
                "activation": "softmax"
              }
            ]

        :param input_names: List of names for the input units (default: TensorFlow name auto-assign logic).
        :param output_names: List of labels for the output units (default: TensorFlow name auto-assign logic).
        :param optimizer: Optimizer, see <https://keras.io/optimizers/> (default: ``rmsprop``).
        :param loss: Loss function, see <https://keras.io/losses/>. An objective function is any callable with
            the signature ``scalar_loss = fn(y_true, y_pred)``. 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 (default: None).

        :param 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']]``. Default: ``['accuracy']``.

        :param 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.

        :param sample_weight_mode: If you need to do time-step-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.

        :param weighted_metrics: List of metrics to be evaluated and weighted by ``sample_weight`` or ``class_weight``
            during training and testing.

        :param 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.

        :param kwargs: Extra arguments to pass to ``Model.compile()``.

        :return: The model configuration, as a dict. Example:

          .. code-block:: json

            {
              "name": "test_model",
              "layers": [
                {
                  "class_name": "Flatten",
                  "config": {
                    "name": "flatten",
                    "trainable": true,
                    "batch_input_shape": [
                      null,
                      10
                    ],
                    "dtype": "float32",
                    "data_format": "channels_last"
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 100,
                    "activation": "relu",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense_1",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 50,
                    "activation": "relu",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense_2",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 2,
                    "activation": "softmax",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                }
              ]
            }

        """
        from tensorflow.keras import Sequential
        model = Sequential(name=name)
        for layer in layers:
            if not isinstance(layer, Layer):
                layer = self._layer_from_dict(layer.pop('type'), **layer)
            model.add(layer)

        if not metrics:
            metrics = ['accuracy']

        model.compile(
            optimizer=optimizer,
            loss=loss,
            metrics=metrics,
            loss_weights=loss_weights,
            sample_weight_mode=sample_weight_mode,
            weighted_metrics=weighted_metrics,
            target_tensors=target_tensors,
            **kwargs
        )

        model.input_labels = input_names or []
        model.output_labels = output_names or []

        with self._lock_model(name):
            self.models[name] = model
        return model.get_config()

        Create a neural network TensorFlow Keras model.

        :param name: Name of the model.
        :param layers: List of layers. Example:

          .. code-block:: javascript

            [
              // Input flatten layer with 10 units
              {
                "type": "Flatten",
                "input_shape": [10, 10]
              },

              // Dense hidden layer with 500 units
              {
                "type": "Dense",
                "units": 500,
                "activation": "relu"
              },

              // Dense hidden layer with 100 units
              {
                "type": "Dense",
                "units": 100,
                "activation": "relu"
              },

              // Dense output layer with 2 units (labels) and ``softmax`` activation function
              {
                "type": "Dense",
                "units": 2,
                "activation": "softmax"
              }
            ]

        :param input_names: List of names for the input units (default: TensorFlow name auto-assign logic).
        :param output_names: List of labels for the output units (default: TensorFlow name auto-assign logic).
        :param optimizer: Optimizer, see <https://keras.io/optimizers/> (default: ``rmsprop``).
        :param loss: Loss function, see <https://keras.io/losses/>. An objective function is any callable with
            the signature ``scalar_loss = fn(y_true, y_pred)``. 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 (default: None).

        :param 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']]``. Default: ``['accuracy']``.

        :param 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.

        :param sample_weight_mode: If you need to do time-step-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.

        :param weighted_metrics: List of metrics to be evaluated and weighted by ``sample_weight`` or ``class_weight``
            during training and testing.

        :param 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.

        :param kwargs: Extra arguments to pass to ``Model.compile()``.

        :return: The model configuration, as a dict. Example:

          .. code-block:: json

            {
              "name": "test_model",
              "layers": [
                {
                  "class_name": "Flatten",
                  "config": {
                    "name": "flatten",
                    "trainable": true,
                    "batch_input_shape": [
                      null,
                      10
                    ],
                    "dtype": "float32",
                    "data_format": "channels_last"
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 100,
                    "activation": "relu",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense_1",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 50,
                    "activation": "relu",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense_2",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 2,
                    "activation": "softmax",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                }
              ]
            }

        
Create a neural network TensorFlow Keras model.
Create a neural network TensorFlow Keras model .
def create_network(self,
                       name: str,
                       layers: List[Union[Layer, Dict[str, Any]]],
                       input_names: Optional[List[str]] = None,
                       output_names: Optional[List[str]] = None,
                       optimizer: Optional[str] = 'rmsprop',
                       loss: Optional[Union[str, List[str], Dict[str, str]]] = None,
                       metrics: Optional[
                           Union[str, List[Union[str, List[str]]], Dict[str, Union[str, List[str]]]]] = None,
                       loss_weights: Optional[Union[List[float], Dict[str, float]]] = None,
                       sample_weight_mode: Optional[Union[str, List[str], Dict[str, str]]] = None,
                       weighted_metrics: Optional[List[str]] = None,
                       target_tensors=None,
                       **kwargs) -> Dict[str, Any]:
        from tensorflow.keras import Sequential
        model = Sequential(name=name)
        for layer in layers:
            if not isinstance(layer, Layer):
                layer = self._layer_from_dict(layer.pop('type'), **layer)
            model.add(layer)
        if not metrics:
            metrics = ['accuracy']
        model.compile(
            optimizer=optimizer,
            loss=loss,
            metrics=metrics,
            loss_weights=loss_weights,
            sample_weight_mode=sample_weight_mode,
            weighted_metrics=weighted_metrics,
            target_tensors=target_tensors,
            **kwargs
        )
        model.input_labels = input_names or []
        model.output_labels = output_names or []
        with self._lock_model(name):
            self.models[name] = model
        return model.get_config()
def create_network ( self , name : str , layers : List [ Union [ Layer , Dict [ str , Any ] ] ] , input_names : Optional [ List [ str ] ] = None , output_names : Optional [ List [ str ] ] = None , optimizer : Optional [ str ] = 'rmsprop' , loss : Optional [ Union [ str , List [ str ] , Dict [ str , str ] ] ] = None , metrics : Optional [ Union [ str , List [ Union [ str , List [ str ] ] ] , Dict [ str , Union [ str , List [ str ] ] ] ] ] = None , loss_weights : Optional [ Union [ List [ float ] , Dict [ str , float ] ] ] = None , sample_weight_mode : Optional [ Union [ str , List [ str ] , Dict [ str , str ] ] ] = None , weighted_metrics : Optional [ List [ str ] ] = None , target_tensors = None , ** kwargs ) -> Dict [ str , Any ] : from tensorflow . keras import Sequential model = Sequential ( name = name ) for layer in layers : if not isinstance ( layer , Layer ) : layer = self . _layer_from_dict ( layer . pop ( 'type' ) , ** layer ) model . add ( layer ) if not metrics : metrics = [ 'accuracy' ] model . compile ( optimizer = optimizer , loss = loss , metrics = metrics , loss_weights = loss_weights , sample_weight_mode = sample_weight_mode , weighted_metrics = weighted_metrics , target_tensors = target_tensors , ** kwargs ) model . input_labels = input_names or [ ] model . output_labels = output_names or [ ] with self . _lock_model ( name ) : self . models [ name ] = model return model . get_config ( )
Create a neural network TensorFlow Keras model.
Create a neural network TensorFlow Keras model .
"""
        Create a neural network TensorFlow Keras model.

        :param name: Name of the model.
        :param layers: List of layers. Example:

          .. code-block:: javascript

            [
              // Input flatten layer with 10 units
              {
                "type": "Flatten",
                "input_shape": [10, 10]
              },

              // Dense hidden layer with 500 units
              {
                "type": "Dense",
                "units": 500,
                "activation": "relu"
              },

              // Dense hidden layer with 100 units
              {
                "type": "Dense",
                "units": 100,
                "activation": "relu"
              },

              // Dense output layer with 2 units (labels) and ``softmax`` activation function
              {
                "type": "Dense",
                "units": 2,
                "activation": "softmax"
              }
            ]

        :param input_names: List of names for the input units (default: TensorFlow name auto-assign logic).
        :param output_names: List of labels for the output units (default: TensorFlow name auto-assign logic).
        :param optimizer: Optimizer, see <https://keras.io/optimizers/> (default: ``rmsprop``).
        :param loss: Loss function, see <https://keras.io/losses/>. An objective function is any callable with
            the signature ``scalar_loss = fn(y_true, y_pred)``. 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 (default: None).

        :param 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']]``. Default: ``['accuracy']``.

        :param 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.

        :param sample_weight_mode: If you need to do time-step-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.

        :param weighted_metrics: List of metrics to be evaluated and weighted by ``sample_weight`` or ``class_weight``
            during training and testing.

        :param 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.

        :param kwargs: Extra arguments to pass to ``Model.compile()``.

        :return: The model configuration, as a dict. Example:

          .. code-block:: json

            {
              "name": "test_model",
              "layers": [
                {
                  "class_name": "Flatten",
                  "config": {
                    "name": "flatten",
                    "trainable": true,
                    "batch_input_shape": [
                      null,
                      10
                    ],
                    "dtype": "float32",
                    "data_format": "channels_last"
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 100,
                    "activation": "relu",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense_1",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 50,
                    "activation": "relu",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                },
                {
                  "class_name": "Dense",
                  "config": {
                    "name": "dense_2",
                    "trainable": true,
                    "dtype": "float32",
                    "units": 2,
                    "activation": "softmax",
                    "use_bias": true,
                    "kernel_initializer": {
                      "class_name": "GlorotUniform",
                      "config": {
                        "seed": null
                      }
                    },
                    "bias_initializer": {
                      "class_name": "Zeros",
                      "config": {}
                    },
                    "kernel_regularizer": null,
                    "bias_regularizer": null,
                    "activity_regularizer": null,
                    "kernel_constraint": null,
                    "bias_constraint": null
                  }
                }
              ]
            }

        """
The model configuration, as a dict. Example:
code-block:: json

{
"name": "test_model",
"layers": [
{
"class_name": "Flatten",
"config": {
"name": "flatten",
"trainable": true,
"batch_input_shape": [
null,
10
],
"dtype": "float32",
"data_format": "channels_last"
}
},
{
"class_name": "Dense",
"config": {
"name": "dense",
"trainable": true,
"dtype": "float32",
"units": 100,
"activation": "relu",
"use_bias": true,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"seed": null
}
},
"bias_initializer": {
"class_name": "Zeros",
"config": {}
},
"kernel_regularizer": null,
"bias_regularizer": null,
"activity_regularizer": null,
"kernel_constraint": null,
"bias_constraint": null
}
},
{
"class_name": "Dense",
"config": {
"name": "dense_1",
"trainable": true,
"dtype": "float32",
"units": 50,
"activation": "relu",
"use_bias": true,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"seed": null
}
},
"bias_initializer": {
"class_name": "Zeros",
"config": {}
},
"kernel_regularizer": null,
"bias_regularizer": null,
"activity_regularizer": null,
"kernel_constraint": null,
"bias_constraint": null
}
},
{
"class_name": "Dense",
"config": {
"name": "dense_2",
"trainable": true,
"dtype": "float32",
"units": 2,
"activation": "softmax",
"use_bias": true,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"seed": null
}
},
"bias_initializer": {
"class_name": "Zeros",
"config": {}
},
"kernel_regularizer": null,
"bias_regularizer": null,
"activity_regularizer": null,
"kernel_constraint": null,
"bias_constraint": null
}
}
]
}
The model configuration as a dict . Example : code - block :: json { " name " : " test_model " " layers " : [ { " class_name " : " Flatten " " config " : { " name " : " flatten " " trainable " : true " batch_input_shape " : [ null 10 ] " dtype " : " float32 " " data_format " : " channels_last " } } { " class_name " : " Dense " " config " : { " name " : " dense " " trainable " : true " dtype " : " float32 " " units " : 100 " activation " : " relu " " use_bias " : true " kernel_initializer " : { " class_name " : " GlorotUniform " " config " : { " seed " : null } } " bias_initializer " : { " class_name " : " Zeros " " config " : {} } " kernel_regularizer " : null " bias_regularizer " : null " activity_regularizer " : null " kernel_constraint " : null " bias_constraint " : null } } { " class_name " : " Dense " " config " : { " name " : " dense_1 " " trainable " : true " dtype " : " float32 " " units " : 50 " activation " : " relu " " use_bias " : true " kernel_initializer " : { " class_name " : " GlorotUniform " " config " : { " seed " : null } } " bias_initializer " : { " class_name " : " Zeros " " config " : {} } " kernel_regularizer " : null " bias_regularizer " : null " activity_regularizer " : null " kernel_constraint " : null " bias_constraint " : null } } { " class_name " : " Dense " " config " : { " name " : " dense_2 " " trainable " : true " dtype " : " float32 " " units " : 2 " activation " : " softmax " " use_bias " : true " kernel_initializer " : { " class_name " : " GlorotUniform " " config " : { " seed " : null } } " bias_initializer " : { " class_name " : " Zeros " " config " : {} } " kernel_regularizer " : null " bias_regularizer " : null " activity_regularizer " : null " kernel_constraint " : null " bias_constraint " : null } } ] }
self
name
str
Name of the model.
Name of the model .
layers
List[Union[Layer, Dict[str, Any]]]
List of layers. Example:
code-block:: javascript

[
Input flatten layer with 10 units
{
"type": "Flatten",
"input_shape": [10, 10]
}.

Dense hidden layer with 500 units
{
"type": "Dense",
"units": 500,
"activation": "relu"
}.

Dense hidden layer with 100 units
{
"type": "Dense",
"units": 100,
"activation": "relu"
}.

Dense output layer with 2 units (labels) and ``softmax`` activation function
{
"type": "Dense",
"units": 2,
"activation": "softmax"
}
]
List of layers . Example : code - block :: javascript [ Input flatten layer with 10 units { " type " : " Flatten " " input_shape " : [ 10 10 ] } . Dense hidden layer with 500 units { " type " : " Dense " " units " : 500 " activation " : " relu " } . Dense hidden layer with 100 units { " type " : " Dense " " units " : 100 " activation " : " relu " } . Dense output layer with 2 units ( labels ) and ` ` softmax ` ` activation function { " type " : " Dense " " units " : 2 " activation " : " softmax " } ]
input_names
Optional[List[str]]
List of names for the input units (default: TensorFlow name auto-assign logic).
List of names for the input units ( default : TensorFlow name auto - assign logic ) .
output_names
Optional[List[str]]
List of labels for the output units (default: TensorFlow name auto-assign logic).
List of labels for the output units ( default : TensorFlow name auto - assign logic ) .
optimizer
Optional[str]
Optimizer, see  (default: ``rmsprop``).
Optimizer see ( default : ` ` rmsprop ` ` ) .
loss
Optional[Union[str, List[str], Dict[str, str]]]
Loss function, see . An objective function is any callable with
the signature ``scalar_loss = fn(y_true, y_pred)``. 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 (default: None).
Loss function see . An objective function is any callable with the signature ` ` scalar_loss = fn ( y_true y_pred ) ` ` . 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 ( default : None ) .
metrics
Optional[
                           Union[str, List[Union[str, List[str]]], Dict[str, Union[str, List[str]]]]]
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']]``.
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 ' ]] ` ` .
loss_weights
Optional[Union[List[float], Dict[str, float]]]
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.
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 .
sample_weight_mode
Optional[Union[str, List[str], Dict[str, str]]]
If you need to do time-step-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.
If you need to do time - step - 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 .
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
weighted_metrics
Optional[List[str]]
List of metrics to be evaluated and weighted by ``sample_weight`` or ``class_weight``
during training and testing.
List of metrics to be evaluated and weighted by ` ` sample_weight ` ` or ` ` class_weight ` ` during training and testing .
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.
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 .
kwargs
Extra arguments to pass to ``Model.compile()``.
Extra arguments to pass to ` ` Model . compile () ` ` .