Package moa.classifiers.deeplearning
Class MLP
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.deeplearning.MLP
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class MLP extends AbstractClassifier implements MultiClassClassifier
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MLP.NormalizeInfo
-
Field Summary
Fields Modifier and Type Field Description FloatOption
backPropLossThreshold
double
deltaForADWIN
MultiChoiceOption
deviceTypeOption
static int
deviceTypeOptionCPU
static int
deviceTypeOptionGPU
IntOption
djlRandomSeed
protected int
featureValuesArraySize
FloatOption
learningRateOption
ADWIN
lossEstimator
IntOption
miniBatchSize
String
modelName
protected ai.djl.Model
nnmodel
protected MLP.NormalizeInfo[]
normalizeInfo
IntOption
numberOfLayers
IntOption
numberOfNeuronsInEachLayerInLog2
static int
OPTIMIZER_ADAGRAD
static int
OPTIMIZER_ADAGRAD_RESET
static int
OPTIMIZER_ADAM
static int
OPTIMIZER_ADAM_RESET
static int
OPTIMIZER_RMSPROP
static int
OPTIMIZER_RMSPROP_RESET
static int
OPTIMIZER_SGD
MultiChoiceOption
optimizerTypeOption
protected long
samplesSeen
protected long
trainedCount
protected ai.djl.training.Trainer
trainer
FlagOption
useNormalization
FlagOption
useOneHotEncode
-
Fields inherited from class moa.classifiers.AbstractClassifier
classifierRandom, modelContext, randomSeed, randomSeedOption, trainingWeightSeenByModel
-
Fields inherited from class moa.options.AbstractOptionHandler
config
-
-
Constructor Summary
Constructors Constructor Description MLP()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableCapabilities
defineImmutableCapabilities()
Defines the set of capabilities the object has.static int
getFeatureValuesArraySize(Instance inst, boolean useOneHotEncoding)
double
getLossEstimation()
void
getModelDescription(StringBuilder out, int indent)
Returns a string representation of the model.protected Measurement[]
getModelMeasurementsImpl()
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods.static double
getNormalizedValue(double value, double sumOfValues, double sumOfSquares, long samplesSeen)
String
getPurposeString()
Dictionary with option texts and objectsdouble[]
getVotesForFeatureValues(Instance inst)
double[]
getVotesForFeatureValues(Instance inst, double[] featureValues)
double[]
getVotesForInstance(Instance inst)
Predicts the class memberships for a given instance.void
initializeNetwork(Instance inst)
boolean
isRandomizable()
Gets whether this learner needs a random seed.void
resetLearningImpl()
Resets this classifier.static void
setFeatureValuesArray(Instance inst, double[] featureValuesArrayToSet, boolean useOneHotEncoding, boolean testing, MLP.NormalizeInfo[] normalizeInfo, long samplesSeen)
protected void
setModel()
protected void
setTrainer()
void
trainOnInstanceImpl(Instance inst)
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods.void
trainOnMiniBatch(moa.classifiers.deeplearning.MiniBatch batch, boolean trainNet)
-
Methods inherited from class moa.classifiers.AbstractClassifier
contextIsCompatible, copy, correctlyClassifies, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getSubClassifiers, getSublearners, getVotesForInstance, modelAttIndexToInstanceAttIndex, modelAttIndexToInstanceAttIndex, prepareForUseImpl, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance, trainOnInstance
-
Methods inherited from class moa.options.AbstractOptionHandler
getCLICreationString, getOptions, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
-
Methods inherited from class moa.AbstractMOAObject
copy, measureByteSize, measureByteSize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface moa.capabilities.CapabilitiesHandler
getCapabilities
-
Methods inherited from interface moa.MOAObject
measureByteSize
-
Methods inherited from interface moa.options.OptionHandler
getCLICreationString, getOptions, prepareForUse, prepareForUse
-
-
-
-
Field Detail
-
OPTIMIZER_SGD
public static final int OPTIMIZER_SGD
- See Also:
- Constant Field Values
-
OPTIMIZER_RMSPROP
public static final int OPTIMIZER_RMSPROP
- See Also:
- Constant Field Values
-
OPTIMIZER_RMSPROP_RESET
public static final int OPTIMIZER_RMSPROP_RESET
- See Also:
- Constant Field Values
-
OPTIMIZER_ADAGRAD
public static final int OPTIMIZER_ADAGRAD
- See Also:
- Constant Field Values
-
OPTIMIZER_ADAGRAD_RESET
public static final int OPTIMIZER_ADAGRAD_RESET
- See Also:
- Constant Field Values
-
OPTIMIZER_ADAM
public static final int OPTIMIZER_ADAM
- See Also:
- Constant Field Values
-
OPTIMIZER_ADAM_RESET
public static final int OPTIMIZER_ADAM_RESET
- See Also:
- Constant Field Values
-
samplesSeen
protected long samplesSeen
-
trainedCount
protected long trainedCount
-
normalizeInfo
protected MLP.NormalizeInfo[] normalizeInfo
-
learningRateOption
public FloatOption learningRateOption
-
backPropLossThreshold
public FloatOption backPropLossThreshold
-
optimizerTypeOption
public MultiChoiceOption optimizerTypeOption
-
useOneHotEncode
public FlagOption useOneHotEncode
-
useNormalization
public FlagOption useNormalization
-
numberOfNeuronsInEachLayerInLog2
public IntOption numberOfNeuronsInEachLayerInLog2
-
numberOfLayers
public IntOption numberOfLayers
-
miniBatchSize
public IntOption miniBatchSize
-
deviceTypeOptionGPU
public static final int deviceTypeOptionGPU
- See Also:
- Constant Field Values
-
deviceTypeOptionCPU
public static final int deviceTypeOptionCPU
- See Also:
- Constant Field Values
-
deviceTypeOption
public MultiChoiceOption deviceTypeOption
-
djlRandomSeed
public IntOption djlRandomSeed
-
deltaForADWIN
public double deltaForADWIN
-
lossEstimator
public ADWIN lossEstimator
-
modelName
public String modelName
-
nnmodel
protected ai.djl.Model nnmodel
-
trainer
protected ai.djl.training.Trainer trainer
-
featureValuesArraySize
protected int featureValuesArraySize
-
-
Method Detail
-
getPurposeString
public String getPurposeString()
Description copied from class:AbstractOptionHandler
Dictionary with option texts and objects- Specified by:
getPurposeString
in interfaceOptionHandler
- Overrides:
getPurposeString
in classAbstractClassifier
- Returns:
- the string with the purpose of this object
-
resetLearningImpl
public void resetLearningImpl()
Description copied from class:AbstractClassifier
Resets this classifier. It must be similar to starting a new classifier from scratch.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
resetLearningImpl
in classAbstractClassifier
-
trainOnMiniBatch
public void trainOnMiniBatch(moa.classifiers.deeplearning.MiniBatch batch, boolean trainNet)
-
trainOnInstanceImpl
public void trainOnInstanceImpl(Instance inst)
Description copied from class:AbstractClassifier
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
trainOnInstanceImpl
in classAbstractClassifier
- Parameters:
inst
- the instance to be used for training
-
getVotesForFeatureValues
public double[] getVotesForFeatureValues(Instance inst, double[] featureValues)
-
getVotesForFeatureValues
public double[] getVotesForFeatureValues(Instance inst)
-
getVotesForInstance
public double[] getVotesForInstance(Instance inst)
Description copied from interface:Classifier
Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero.- Specified by:
getVotesForInstance
in interfaceClassifier
- Specified by:
getVotesForInstance
in classAbstractClassifier
- Parameters:
inst
- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class
-
defineImmutableCapabilities
public ImmutableCapabilities defineImmutableCapabilities()
Description copied from interface:CapabilitiesHandler
Defines the set of capabilities the object has. Should be overridden if the object's capabilities do not change.- Specified by:
defineImmutableCapabilities
in interfaceCapabilitiesHandler
- Overrides:
defineImmutableCapabilities
in classAbstractClassifier
- Returns:
- The capabilities of the object.
-
getModelMeasurementsImpl
protected Measurement[] getModelMeasurementsImpl()
Description copied from class:AbstractClassifier
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
getModelMeasurementsImpl
in classAbstractClassifier
- Returns:
- an array of measurements to be used in evaluation tasks
-
getModelDescription
public void getModelDescription(StringBuilder out, int indent)
Description copied from class:AbstractClassifier
Returns a string representation of the model.- Specified by:
getModelDescription
in classAbstractClassifier
- Parameters:
out
- the stringbuilder to add the descriptionindent
- the number of characters to indent
-
isRandomizable
public boolean isRandomizable()
Description copied from interface:Learner
Gets whether this learner needs a random seed. Examples of methods that needs a random seed are bagging and boosting.- Specified by:
isRandomizable
in interfaceLearner<Example<Instance>>
- Returns:
- true if the learner needs a random seed.
-
getFeatureValuesArraySize
public static int getFeatureValuesArraySize(Instance inst, boolean useOneHotEncoding)
-
getNormalizedValue
public static double getNormalizedValue(double value, double sumOfValues, double sumOfSquares, long samplesSeen)
-
setFeatureValuesArray
public static void setFeatureValuesArray(Instance inst, double[] featureValuesArrayToSet, boolean useOneHotEncoding, boolean testing, MLP.NormalizeInfo[] normalizeInfo, long samplesSeen)
-
initializeNetwork
public void initializeNetwork(Instance inst)
-
getLossEstimation
public double getLossEstimation()
-
setModel
protected void setModel()
-
setTrainer
protected void setTrainer()
-
-