platypush/plugins/tensorflow/__init__.py
def train(self,
              model: str,
              inputs: Union[str, np.ndarray, Iterable, Dict[str, Union[Iterable, np.ndarray]]],
              outputs: Optional[Union[str, np.ndarray, Iterable]] = None,
              batch_size: Optional[int] = None,
              epochs: int = 1,
              verbose: int = 1,
              validation_split: float = 0.,
              validation_data: Optional[Tuple[Union[np.ndarray, Iterable]]] = None,
              shuffle: Union[bool, str] = True,
              class_weight: Optional[Dict[int, float]] = None,
              sample_weight: Optional[Union[np.ndarray, Iterable]] = None,
              initial_epoch: int = 0,
              steps_per_epoch: Optional[int] = None,
              validation_steps: int = None,
              validation_freq: int = 1,
              max_queue_size: int = 10,
              workers: int = 1,
              use_multiprocessing: bool = False) -> TensorflowTrainResponse:
        """
        Trains a model on a dataset for a fixed number of epochs.

        :param model: Name of the model. It can be a folder name stored under ``<workdir>/models``, or an absolute path
            to a model directory or file (Tensorflow directories, Protobuf models and HDF5 files are supported).
        :param inputs: Input data. It can 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)``.
          - A string that points to a file. Supported formats:

              - CSV with header (``.csv`` extension``)
              - Numpy raw or compressed files (``.npy`` or ``.npz`` extension)
              - Image files
              - An HTTP URL pointing to one of the file types listed above
              - Directories with images. If ``inputs`` points to a directory of images then the following
                conventions are followed:

                - The folder must contain exactly as many subfolders as the output units of your model. If
                  the model has ``output_labels`` then those subfolders should be named as the output labels.
                  Each subfolder will contain training examples that match the associated label (e.g.
                  ``positive`` will contain all the positive images and ``negative`` all the negative images).
                - ``outputs`` doesn't have to be specified.

        :param outputs: Target data. Like the input data `x`, it can be a numpy array (or array-like) 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`).

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

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

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

        :param 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. Not supported when ``x`` is a dataset, generator or ``keras.utils.Sequence`` instance.

        :param 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 arrays/numpy arrays/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`` could be
            provided.

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

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

        :param sample_weight: Optional iterable/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/iterable 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
            time step 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``.

        :param initial_epoch: Epoch at which to start training (useful for resuming a previous training run).

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

        :param 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_steps' is None, validation will run until the ``validation_data`` dataset is
            exhausted. In the case of a infinite dataset, it will run into a infinite loop. If 'validation_steps' is
            specified and only part of the dataset will be consumed, the evaluation will start from the beginning of
            the dataset at each epoch. This ensures that the same validation samples are used every time.

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

        :param max_queue_size: Used for generator or ``keras.utils.Sequence`` input only. Maximum size for
            the generator queue. If unspecified, ``max_queue_size`` will default to 10.

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

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

        :return: :class:`platypush.message.response.tensorflow.TensorflowTrainResponse`
        """
        name = model
        model = self._load_model(model)
        inputs, outputs = self._get_dataset(inputs, outputs, model)

        ret = model.fit(
            x=inputs,
            y=outputs,
            batch_size=batch_size,
            epochs=epochs,
            verbose=verbose,
            callbacks=self._generate_callbacks(name),
            validation_split=validation_split,
            validation_data=validation_data,
            shuffle=shuffle,
            class_weight=class_weight,
            sample_weight=sample_weight,
            initial_epoch=initial_epoch,
            steps_per_epoch=steps_per_epoch,
            validation_steps=validation_steps,
            validation_freq=validation_freq,
            max_queue_size=max_queue_size,
            workers=workers,
            use_multiprocessing=use_multiprocessing,
        )

        return TensorflowTrainResponse(model=model, model_name=name, epochs=ret.epoch, history=ret.history)

        Trains a model on a dataset for a fixed number of epochs.

        :param model: Name of the model. It can be a folder name stored under ``<workdir>/models``, or an absolute path
            to a model directory or file (Tensorflow directories, Protobuf models and HDF5 files are supported).
        :param inputs: Input data. It can 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)``.
          - A string that points to a file. Supported formats:

              - CSV with header (``.csv`` extension``)
              - Numpy raw or compressed files (``.npy`` or ``.npz`` extension)
              - Image files
              - An HTTP URL pointing to one of the file types listed above
              - Directories with images. If ``inputs`` points to a directory of images then the following
                conventions are followed:

                - The folder must contain exactly as many subfolders as the output units of your model. If
                  the model has ``output_labels`` then those subfolders should be named as the output labels.
                  Each subfolder will contain training examples that match the associated label (e.g.
                  ``positive`` will contain all the positive images and ``negative`` all the negative images).
                - ``outputs`` doesn't have to be specified.

        :param outputs: Target data. Like the input data `x`, it can be a numpy array (or array-like) 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`).

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

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

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

        :param 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. Not supported when ``x`` is a dataset, generator or ``keras.utils.Sequence`` instance.

        :param 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 arrays/numpy arrays/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`` could be
            provided.

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

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

        :param sample_weight: Optional iterable/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/iterable 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
            time step 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``.

        :param initial_epoch: Epoch at which to start training (useful for resuming a previous training run).

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

        :param 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_steps' is None, validation will run until the ``validation_data`` dataset is
            exhausted. In the case of a infinite dataset, it will run into a infinite loop. If 'validation_steps' is
            specified and only part of the dataset will be consumed, the evaluation will start from the beginning of
            the dataset at each epoch. This ensures that the same validation samples are used every time.

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

        :param max_queue_size: Used for generator or ``keras.utils.Sequence`` input only. Maximum size for
            the generator queue. If unspecified, ``max_queue_size`` will default to 10.

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

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

        :return: :class:`platypush.message.response.tensorflow.TensorflowTrainResponse`
        
Trains a model on a dataset for a fixed number of epochs.
Trains a model on a dataset for a fixed number of epochs .
def train(self,
              model: str,
              inputs: Union[str, np.ndarray, Iterable, Dict[str, Union[Iterable, np.ndarray]]],
              outputs: Optional[Union[str, np.ndarray, Iterable]] = None,
              batch_size: Optional[int] = None,
              epochs: int = 1,
              verbose: int = 1,
              validation_split: float = 0.,
              validation_data: Optional[Tuple[Union[np.ndarray, Iterable]]] = None,
              shuffle: Union[bool, str] = True,
              class_weight: Optional[Dict[int, float]] = None,
              sample_weight: Optional[Union[np.ndarray, Iterable]] = None,
              initial_epoch: int = 0,
              steps_per_epoch: Optional[int] = None,
              validation_steps: int = None,
              validation_freq: int = 1,
              max_queue_size: int = 10,
              workers: int = 1,
              use_multiprocessing: bool = False) -> TensorflowTrainResponse:
        name = model
        model = self._load_model(model)
        inputs, outputs = self._get_dataset(inputs, outputs, model)
        ret = model.fit(
            x=inputs,
            y=outputs,
            batch_size=batch_size,
            epochs=epochs,
            verbose=verbose,
            callbacks=self._generate_callbacks(name),
            validation_split=validation_split,
            validation_data=validation_data,
            shuffle=shuffle,
            class_weight=class_weight,
            sample_weight=sample_weight,
            initial_epoch=initial_epoch,
            steps_per_epoch=steps_per_epoch,
            validation_steps=validation_steps,
            validation_freq=validation_freq,
            max_queue_size=max_queue_size,
            workers=workers,
            use_multiprocessing=use_multiprocessing,
        )
        return TensorflowTrainResponse(model=model, model_name=name, epochs=ret.epoch, history=ret.history)
def train ( self , model : str , inputs : Union [ str , np . ndarray , Iterable , Dict [ str , Union [ Iterable , np . ndarray ] ] ] , outputs : Optional [ Union [ str , np . ndarray , Iterable ] ] = None , batch_size : Optional [ int ] = None , epochs : int = 1 , verbose : int = 1 , validation_split : float = 0. , validation_data : Optional [ Tuple [ Union [ np . ndarray , Iterable ] ] ] = None , shuffle : Union [ bool , str ] = True , class_weight : Optional [ Dict [ int , float ] ] = None , sample_weight : Optional [ Union [ np . ndarray , Iterable ] ] = None , initial_epoch : int = 0 , steps_per_epoch : Optional [ int ] = None , validation_steps : int = None , validation_freq : int = 1 , max_queue_size : int = 10 , workers : int = 1 , use_multiprocessing : bool = False ) -> TensorflowTrainResponse : name = model model = self . _load_model ( model ) inputs , outputs = self . _get_dataset ( inputs , outputs , model ) ret = model . fit ( x = inputs , y = outputs , batch_size = batch_size , epochs = epochs , verbose = verbose , callbacks = self . _generate_callbacks ( name ) , validation_split = validation_split , validation_data = validation_data , shuffle = shuffle , class_weight = class_weight , sample_weight = sample_weight , initial_epoch = initial_epoch , steps_per_epoch = steps_per_epoch , validation_steps = validation_steps , validation_freq = validation_freq , max_queue_size = max_queue_size , workers = workers , use_multiprocessing = use_multiprocessing , ) return TensorflowTrainResponse ( model = model , model_name = name , epochs = ret . epoch , history = ret . history )
Trains a model on a dataset for a fixed number of epochs.
Trains a model on a dataset for a fixed number of epochs .
"""
        Trains a model on a dataset for a fixed number of epochs.

        :param model: Name of the model. It can be a folder name stored under ``<workdir>/models``, or an absolute path
            to a model directory or file (Tensorflow directories, Protobuf models and HDF5 files are supported).
        :param inputs: Input data. It can 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)``.
          - A string that points to a file. Supported formats:

              - CSV with header (``.csv`` extension``)
              - Numpy raw or compressed files (``.npy`` or ``.npz`` extension)
              - Image files
              - An HTTP URL pointing to one of the file types listed above
              - Directories with images. If ``inputs`` points to a directory of images then the following
                conventions are followed:

                - The folder must contain exactly as many subfolders as the output units of your model. If
                  the model has ``output_labels`` then those subfolders should be named as the output labels.
                  Each subfolder will contain training examples that match the associated label (e.g.
                  ``positive`` will contain all the positive images and ``negative`` all the negative images).
                - ``outputs`` doesn't have to be specified.

        :param outputs: Target data. Like the input data `x`, it can be a numpy array (or array-like) 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`).

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

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

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

        :param 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. Not supported when ``x`` is a dataset, generator or ``keras.utils.Sequence`` instance.

        :param 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 arrays/numpy arrays/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`` could be
            provided.

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

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

        :param sample_weight: Optional iterable/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/iterable 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
            time step 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``.

        :param initial_epoch: Epoch at which to start training (useful for resuming a previous training run).

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

        :param 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_steps' is None, validation will run until the ``validation_data`` dataset is
            exhausted. In the case of a infinite dataset, it will run into a infinite loop. If 'validation_steps' is
            specified and only part of the dataset will be consumed, the evaluation will start from the beginning of
            the dataset at each epoch. This ensures that the same validation samples are used every time.

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

        :param max_queue_size: Used for generator or ``keras.utils.Sequence`` input only. Maximum size for
            the generator queue. If unspecified, ``max_queue_size`` will default to 10.

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

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

        :return: :class:`platypush.message.response.tensorflow.TensorflowTrainResponse`
        """
None
self
model
str
Name of the model. It can be a folder name stored under ``/models``, or an absolute path
to a model directory or file (Tensorflow directories, Protobuf models and HDF5 files are supported).
Name of the model . It can be a folder name stored under ` ` / models ` ` or an absolute path to a model directory or file ( Tensorflow directories Protobuf models and HDF5 files are supported ) .
inputs
Union[str, np.ndarray, Iterable, Dict[str, Union[Iterable, np.ndarray]]]
Input data. It can 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)``.
A string that points to a file. Supported formats.

CSV with header (``.csv`` extension``)
Numpy raw or compressed files (``.npy`` or ``.npz`` extension)
Image files
An HTTP URL pointing to one of the file types listed above
Directories with images. If ``inputs`` points to a directory of images then the following
conventions are followed.

The folder must contain exactly as many subfolders as the output units of your model. If
the model has ``output_labels`` then those subfolders should be named as the output labels.
Each subfolder will contain training examples that match the associated label .
``outputs`` doesn't have to be specified.
Input data . It can 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 ) ` ` . A string that points to a file . Supported formats . CSV with header ( ` ` . csv ` ` extension ` ` ) Numpy raw or compressed files ( ` ` . npy ` ` or ` ` . npz ` ` extension ) Image files An HTTP URL pointing to one of the file types listed above Directories with images . If ` ` inputs ` ` points to a directory of images then the following conventions are followed . The folder must contain exactly as many subfolders as the output units of your model . If the model has ` ` output_labels ` ` then those subfolders should be named as the output labels . Each subfolder will contain training examples that match the associated label . ` ` outputs ` ` doesn ' t have to be specified .
outputs
Optional[Union[str, np.ndarray, Iterable]]
Target data. Like the input data `x`, it can be a numpy array (or array-like) 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`).
Target data . Like the input data ` x ` it can be a numpy array ( or array - like ) 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 ` ) .
batch_size
Optional[int]
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).
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 ) .
epochs
int
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.
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 .
verbose
int
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 .
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 .
validation_split
float
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. Not supported when ``x`` is a dataset, generator or ``keras.utils.Sequence`` instance.
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 . Not supported when ` ` x ` ` is a dataset generator or ` ` keras . utils . Sequence ` ` instance .
validation_data
Optional[Tuple[Union[np.ndarray, Iterable]]]
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 arrays/numpy arrays/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`` could be
provided.
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 arrays / numpy arrays / 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 ` ` could be provided .
shuffle
Union[bool, str]
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``.
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 ` ` .
class_weight
Optional[Dict[int, float]]
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.
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 .
sample_weight
Optional[Union[np.ndarray, Iterable]]
Optional iterable/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/iterable 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
time step 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``.
Optional iterable / 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 / iterable 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 time step 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 ` ` .
initial_epoch
int
Epoch at which to start training (useful for resuming a previous training run).
Epoch at which to start training ( useful for resuming a previous training run ) .
steps_per_epoch
Optional[int]
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.
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 .
validation_steps
int
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_steps' is None, validation will run until the ``validation_data`` dataset is
exhausted. In the case of a infinite dataset, it will run into a infinite loop. If 'validation_steps' is
specified and only part of the dataset will be consumed, the evaluation will start from the beginning of
the dataset at each epoch. This ensures that the same validation samples are used every time.
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_steps ' is None validation will run until the ` ` validation_data ` ` dataset is exhausted . In the case of a infinite dataset it will run into a infinite loop . If ' validation_steps ' is specified and only part of the dataset will be consumed the evaluation will start from the beginning of the dataset at each epoch . This ensures that the same validation samples are used every time .
validation_freq
int
Only relevant if validation data is provided. Integer or ``collections_abc.Container``
instance . 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.
Only relevant if validation data is provided . Integer or ` ` collections_abc . Container ` ` instance . 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 .
max_queue_size
int
Used for generator or ``keras.utils.Sequence`` input only. Maximum size for
the generator queue. If unspecified, ``max_queue_size`` will default to 10.
Used for generator or ` ` keras . utils . Sequence ` ` input only . Maximum size for the generator queue . If unspecified ` ` max_queue_size ` ` will default to 10 .
workers
int
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.
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 .
use_multiprocessing
bool
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.
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 .