I
- Type of input of model produced by first trainer.O1
- Type of output of model produced by first trainer.O2
- Type of output of model produced by second trainer.L
- Type of labels.public class TrainersSequentialComposition<I,O1,O2,L> extends DatasetTrainer<ModelsSequentialComposition<I,O1,O2>,L>
ModelsSequentialComposition
.
Training is done in following fashion:
1. First trainer is trained and `mdl1` is produced. 2. From `mdl1`DatasetMapping
is constructed. This mapping `dsM` encapsulates dependency between first training result and second trainer. 3. Second trainer is trained using dataset aquired from application `dsM` to original dataset; `mdl2` is produced. 4. `mdl1` and `mdl2` are composed intoModelsSequentialComposition
.
DatasetTrainer.EmptyDatasetException
Modifier and Type | Field and Description |
---|---|
protected IgniteBiFunction<Integer,? super IgniteModel<I,O1>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> |
datasetMapping
Dataset mapping.
|
envBuilder, environment
Constructor and Description |
---|
TrainersSequentialComposition(DatasetTrainer<? extends IgniteModel<I,O1>,L> tr1,
DatasetTrainer<? extends IgniteModel<O1,O2>,L> tr2,
IgniteBiFunction<Integer,? super IgniteModel<I,O1>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> datasetMapping)
Create sequential composition of two trainers.
|
TrainersSequentialComposition(DatasetTrainer<? extends IgniteModel<I,O1>,L> tr1,
DatasetTrainer<? extends IgniteModel<O1,O2>,L> tr2,
IgniteFunction<? super IgniteModel<I,O1>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> datasetMapping)
Construct sequential composition of given two trainers.
|
Modifier and Type | Method and Description |
---|---|
<K,V> ModelsSequentialComposition<I,O1,O2> |
fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder,
Preprocessor<K,V> preprocessor)
Trains model based on the specified data.
|
boolean |
isUpdateable(ModelsSequentialComposition<I,O1,O2> mdl)
This method is never called, instead of constructing logic of update from
DatasetTrainer.isUpdateable(M) and
DatasetTrainer.updateModel(M, org.apache.ignite.ml.dataset.DatasetBuilder<K, V>, org.apache.ignite.ml.preprocessing.Preprocessor<K, V>)
in this class we explicitly override update method. |
static <I,O,L> TrainersSequentialComposition<I,O,O,L> |
ofSame(DatasetTrainer<? extends IgniteModel<I,O>,L> tr,
IgniteBiFunction<Integer,? super IgniteModel<I,O>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> datasetMapping,
IgniteBiPredicate<Integer,IgniteModel<I,O>> shouldStop,
IgniteFunction<O,I> out2In)
Construct sequential composition of same trainers.
|
DatasetTrainer<IgniteModel<I,O2>,L> |
unsafeSimplyTyped()
Performs coersion of this trainer to
DatasetTrainer<IgniteModel<I, O2>, L> . |
<K,V> ModelsSequentialComposition<I,O1,O2> |
update(ModelsSequentialComposition<I,O1,O2> mdl,
DatasetBuilder<K,V> datasetBuilder,
Preprocessor<K,V> preprocessor)
Gets state of model in arguments, compare it with training parameters of trainer and if they are fit then trainer
updates model in according to new data and return new model.
|
protected <K,V> ModelsSequentialComposition<I,O1,O2> |
updateModel(ModelsSequentialComposition<I,O1,O2> mdl,
DatasetBuilder<K,V> datasetBuilder,
Preprocessor<K,V> preprocessor)
This method is never called, instead of constructing logic of update from
DatasetTrainer.isUpdateable(IgniteModel) and
DatasetTrainer.updateModel(IgniteModel, DatasetBuilder, Preprocessor)
in this class we explicitly override update method. |
fit, fit, fit, fit, fit, fit, getLastTrainedModelOrThrowEmptyDatasetException, identityTrainer, learningEnvironment, update, update, update, update, withConvertedLabels, withEnvironmentBuilder
protected IgniteBiFunction<Integer,? super IgniteModel<I,O1>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> datasetMapping
public TrainersSequentialComposition(DatasetTrainer<? extends IgniteModel<I,O1>,L> tr1, DatasetTrainer<? extends IgniteModel<O1,O2>,L> tr2, IgniteFunction<? super IgniteModel<I,O1>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> datasetMapping)
tr1
- First trainer.tr2
- Second trainer.datasetMapping
- Dataset mapping.public TrainersSequentialComposition(DatasetTrainer<? extends IgniteModel<I,O1>,L> tr1, DatasetTrainer<? extends IgniteModel<O1,O2>,L> tr2, IgniteBiFunction<Integer,? super IgniteModel<I,O1>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> datasetMapping)
tr1
- First trainer.tr2
- Second trainer.datasetMapping
- Dataset mapping containing dependence between first and second trainer.public static <I,O,L> TrainersSequentialComposition<I,O,O,L> ofSame(DatasetTrainer<? extends IgniteModel<I,O>,L> tr, IgniteBiFunction<Integer,? super IgniteModel<I,O>,IgniteFunction<LabeledVector<L>,LabeledVector<L>>> datasetMapping, IgniteBiPredicate<Integer,IgniteModel<I,O>> shouldStop, IgniteFunction<O,I> out2In)
I
- Type of input of model produced by trainer.O
- Type of output of model produced by trainer.L
- Type of labels for trainer.tr
- Trainer used for sequential composition.datasetMapping
- Dataset mapping.shouldStop
- Predicate depending on index and model produced by the last trainer
indicating if composition process should stopout2In
- Function for conversion of output of model into input of next model.public <K,V> ModelsSequentialComposition<I,O1,O2> fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)
fitWithInitializedDeployingContext
in class DatasetTrainer<ModelsSequentialComposition<I,O1,O2>,L>
K
- Type of a key in upstream
data.V
- Type of a value in upstream
data.datasetBuilder
- Dataset builder.preprocessor
- Extractor of UpstreamEntry
into LabeledVector
.protected <K,V> ModelsSequentialComposition<I,O1,O2> updateModel(ModelsSequentialComposition<I,O1,O2> mdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)
DatasetTrainer.isUpdateable(IgniteModel)
and
DatasetTrainer.updateModel(IgniteModel, DatasetBuilder, Preprocessor)
in this class we explicitly override update method.updateModel
in class DatasetTrainer<ModelsSequentialComposition<I,O1,O2>,L>
K
- Type of a key in upstream
data.V
- Type of a value in upstream
data.mdl
- Model.datasetBuilder
- Dataset builder.preprocessor
- Extractor of UpstreamEntry
into LabeledVector
.public <K,V> ModelsSequentialComposition<I,O1,O2> update(ModelsSequentialComposition<I,O1,O2> mdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)
update
in class DatasetTrainer<ModelsSequentialComposition<I,O1,O2>,L>
K
- Type of a key in upstream
data.V
- Type of a value in upstream
data.mdl
- Learned model.datasetBuilder
- Dataset builder.preprocessor
- Extractor of UpstreamEntry
into LabeledVector
.public boolean isUpdateable(ModelsSequentialComposition<I,O1,O2> mdl)
DatasetTrainer.isUpdateable(M)
and
DatasetTrainer.updateModel(M, org.apache.ignite.ml.dataset.DatasetBuilder<K, V>, org.apache.ignite.ml.preprocessing.Preprocessor<K, V>)
in this class we explicitly override update method.isUpdateable
in class DatasetTrainer<ModelsSequentialComposition<I,O1,O2>,L>
mdl
- Model.public DatasetTrainer<IgniteModel<I,O2>,L> unsafeSimplyTyped()
DatasetTrainer<IgniteModel<I, O2>, L>
.DatasetTrainer<IgniteModel<I, O>, L>
.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024