org.apache.ignite.ml.nn

## Class MLPTrainer<P extends Serializable>

- java.lang.Object
- - org.apache.ignite.ml.trainers.DatasetTrainer<M,double[]>
  - - org.apache.ignite.ml.trainers.MultiLabelDatasetTrainer<MultilayerPerceptron>
    - - org.apache.ignite.ml.nn.MLPTrainer<P>

- Type Parameters:
    `P` - Type of model update used in this trainer.

      public class MLPTrainer<P extends Serializable>
      extends MultiLabelDatasetTrainer<MultilayerPerceptron>

  Multilayer perceptron trainer based on partition based `Dataset`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `DatasetTrainer.EmptyDatasetException`

  - ### Field Summary

    - ### Fields inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `envBuilder, environment`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MLPTrainer(IgniteFunction<Dataset<EmptyContext,SimpleLabeledDatasetData>,MLPArchitecture> archSupplier, IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss, UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy, int maxIterations, int batchSize, int locIterations, long seed)` Constructs a new instance of multilayer perceptron trainer.
    `MLPTrainer(MLPArchitecture arch, IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss, UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy, int maxIterations, int batchSize, int locIterations, long seed)` Constructs a new instance of multilayer perceptron trainer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> MultilayerPerceptron` | `fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> extractor)` Trains model based on the specified data.
    `IgniteFunction<Dataset<EmptyContext,SimpleLabeledDatasetData>,MLPArchitecture>` | `getArchSupplier()` Get the multilayer perceptron architecture supplier that defines layers and activators.
    `int` | `getBatchSize()` Get the batch size (per every partition).
    `int` | `getLocIterations()` Get the maximal number of local iterations before synchronization.
    `IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction>` | `getLoss()` Get the loss function to be minimized during the training.
    `int` | `getMaxIterations()` Get the maximal number of iterations before the training will be stopped.
    `long` | `getSeed()` Get the multilayer perceptron model initializer.
    `UpdatesStrategy<? super MultilayerPerceptron,P>` | `getUpdatesStgy()` Get the update strategy that defines how to update model parameters during the training.
    `boolean` | `isUpdateable(MultilayerPerceptron mdl)`
    `protected <K,V> MultilayerPerceptron` | `updateModel(MultilayerPerceptron lastLearnedMdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> extractor)` Gets state of model in arguments, update in according to new data and return new model.
    `MLPTrainer<P>` | `withArchSupplier(IgniteFunction<Dataset<EmptyContext,SimpleLabeledDatasetData>,MLPArchitecture> archSupplier)` Set up the multilayer perceptron architecture supplier that defines layers and activators.
    `MLPTrainer<P>` | `withBatchSize(int batchSize)` Set up the batch size (per every partition).
    `MLPTrainer<P>` | `withEnvironmentBuilder(LearningEnvironmentBuilder envBuilder)` Changes learning Environment.
    `MLPTrainer<P>` | `withLocIterations(int locIterations)` Set up the maximal number of local iterations before synchronization.
    `MLPTrainer<P>` | `withLoss(IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss)` Set up the loss function to be minimized during the training.
    `MLPTrainer<P>` | `withMaxIterations(int maxIterations)` Set up the maximal number of iterations before the training will be stopped.
    `MLPTrainer<P>` | `withSeed(long seed)` Set up the multilayer perceptron model initializer.
    `MLPTrainer<P>` | `withUpdatesStgy(UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy)` Set up the update strategy that defines how to update model parameters during the training.

    - ### Methods inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `fit, fit, fit, fit, fit, fit, getLastTrainedModelOrThrowEmptyDatasetException, identityTrainer, learningEnvironment, update, update, update, update, update, withConvertedLabels`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MLPTrainer

          public MLPTrainer(MLPArchitecture arch,
                            IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss,
                            UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy,
                            int maxIterations,
                            int batchSize,
                            int locIterations,
                            long seed)

      Constructs a new instance of multilayer perceptron trainer.
      Parameters:
        `arch` - Multilayer perceptron architecture that defines layers and activators.
        `loss` - Loss function to be minimized during the training.
        `updatesStgy` - Update strategy that defines how to update model parameters during the training.
        `maxIterations` - Maximal number of iterations before the training will be stopped.
        `batchSize` - Batch size (per every partition).
        `locIterations` - Maximal number of local iterations before synchronization.
        `seed` - Random initializer seed.

    - #### MLPTrainer

          public MLPTrainer(IgniteFunction<Dataset<EmptyContext,SimpleLabeledDatasetData>,MLPArchitecture> archSupplier,
                            IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss,
                            UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy,
                            int maxIterations,
                            int batchSize,
                            int locIterations,
                            long seed)

      Constructs a new instance of multilayer perceptron trainer.
      Parameters:
        `archSupplier` - Multilayer perceptron architecture supplier that defines layers and activators.
        `loss` - Loss function to be minimized during the training.
        `updatesStgy` - Update strategy that defines how to update model parameters during the training.
        `maxIterations` - Maximal number of iterations before the training will be stopped.
        `batchSize` - Batch size (per every partition).
        `locIterations` - Maximal number of local iterations before synchronization.
        `seed` - Random initializer seed.

  - ### Method Detail

    - #### fitWithInitializedDeployingContext

          public <K,V> MultilayerPerceptron fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder,
                                                                               Preprocessor<K,V> extractor)

      Trains model based on the specified data.
      Specified by:
        `fitWithInitializedDeployingContext` in class `DatasetTrainer<MultilayerPerceptron,double[]>`
      Type Parameters:
        `K` - Type of a key in `upstream` data.
        `V` - Type of a value in `upstream` data.
      Parameters:
        `datasetBuilder` - Dataset builder.
        `extractor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Model.

    - #### updateModel

          protected <K,V> MultilayerPerceptron updateModel(MultilayerPerceptron lastLearnedMdl,
                                                           DatasetBuilder<K,V> datasetBuilder,
                                                           Preprocessor<K,V> extractor)

      Gets state of model in arguments, update in according to new data and return new model.
      Specified by:
        `updateModel` in class `DatasetTrainer<MultilayerPerceptron,double[]>`
      Type Parameters:
        `K` - Type of a key in `upstream` data.
        `V` - Type of a value in `upstream` data.
      Parameters:
        `lastLearnedMdl` - Learned model.
        `datasetBuilder` - Dataset builder.
        `extractor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Updated model.

    - #### getArchSupplier

          public IgniteFunction<Dataset<EmptyContext,SimpleLabeledDatasetData>,MLPArchitecture> getArchSupplier()

      Get the multilayer perceptron architecture supplier that defines layers and activators.
      Returns:
        The property value.

    - #### withArchSupplier

          public MLPTrainer<P> withArchSupplier(IgniteFunction<Dataset<EmptyContext,SimpleLabeledDatasetData>,MLPArchitecture> archSupplier)

      Set up the multilayer perceptron architecture supplier that defines layers and activators.
      Parameters:
        `archSupplier` - The parameter value.
      Returns:
        Model with the multilayer perceptron architecture supplier that defines layers and activators.

    - #### getLoss

          public IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> getLoss()

      Get the loss function to be minimized during the training.
      Returns:
        The property value.

    - #### withLoss

          public MLPTrainer<P> withLoss(IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss)

      Set up the loss function to be minimized during the training.
      Parameters:
        `loss` - The parameter value.
      Returns:
        Model with the loss function to be minimized during the training.

    - #### getUpdatesStgy

          public UpdatesStrategy<? super MultilayerPerceptron,P> getUpdatesStgy()

      Get the update strategy that defines how to update model parameters during the training.
      Returns:
        The property value.

    - #### withUpdatesStgy

          public MLPTrainer<P> withUpdatesStgy(UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy)

      Set up the update strategy that defines how to update model parameters during the training.
      Parameters:
        `updatesStgy` - The parameter value.
      Returns:
        Model with the update strategy that defines how to update model parameters during the training.

    - #### getMaxIterations

          public int getMaxIterations()

      Get the maximal number of iterations before the training will be stopped.
      Returns:
        The property value.

    - #### withMaxIterations

          public MLPTrainer<P> withMaxIterations(int maxIterations)

      Set up the maximal number of iterations before the training will be stopped.
      Parameters:
        `maxIterations` - The parameter value.
      Returns:
        Model with the maximal number of iterations before the training will be stopped.

    - #### getBatchSize

          public int getBatchSize()

      Get the batch size (per every partition).
      Returns:
        The property value.

    - #### withBatchSize

          public MLPTrainer<P> withBatchSize(int batchSize)

      Set up the batch size (per every partition).
      Parameters:
        `batchSize` - The parameter value.
      Returns:
        Model with the batch size (per every partition).

    - #### getLocIterations

          public int getLocIterations()

      Get the maximal number of local iterations before synchronization.
      Returns:
        The property value.

    - #### withLocIterations

          public MLPTrainer<P> withLocIterations(int locIterations)

      Set up the maximal number of local iterations before synchronization.
      Parameters:
        `locIterations` - The parameter value.
      Returns:
        Model with the maximal number of local iterations before synchronization.

    - #### getSeed

          public long getSeed()

      Get the multilayer perceptron model initializer.
      Returns:
        The property value.

    - #### withSeed

          public MLPTrainer<P> withSeed(long seed)

      Set up the multilayer perceptron model initializer.
      Parameters:
        `seed` - The parameter value.
      Returns:
        Model with the multilayer perceptron model initializer.

    - #### isUpdateable

          public boolean isUpdateable(MultilayerPerceptron mdl)

      Specified by:
        `isUpdateable` in class `DatasetTrainer<MultilayerPerceptron,double[]>`
      Parameters:
        `mdl` - Model.
      Returns:
        True if current critical for training parameters correspond to parameters from last training.

    - #### withEnvironmentBuilder

          public MLPTrainer<P> withEnvironmentBuilder(LearningEnvironmentBuilder envBuilder)

      Changes learning Environment.
      Overrides:
        `withEnvironmentBuilder` in class `DatasetTrainer<MultilayerPerceptron,double[]>`
      Parameters:
        `envBuilder` - Learning environment builder.

${current.year} Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.15.0
Release Date | : April 25 2023