Class CAND
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.deeplearning.CAND
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class CAND extends AbstractClassifier implements MultiClassClassifier, CapabilitiesHandler
Continuously Adaptive Neural networks for Data streamsContinuously Adaptive Neural networks for Data streams (CAND). For every prediction, CAND chooses the current best network from a pool of candidates by continuously monitoring the performance of all candidate networks. The candidates are trained using different optimizers and hyperparameters. There are two orthogonal heuristics (skip back propagation, smaller training pool) for accelerating CAND, which trade-off small amounts of accuracy for significant runtime gains. When training, small mini-batches yields similar accuracy to single-instance fully incremental training, even on evolving data streams.
See details in:
Nuwan Gunasekara, Heitor Murilo Gomes, Bernhard Pfahringer, Albert Bifet. Online Hyperparameter Optimization for Streaming Neural Networks. International Joint Conference on Neural Networks (IJCNN), 2022.Parameters:
- -P : The larger pool type. P10 = { learning rates: 5.0E-(1 to 5), optimizes: SGD,Adam, neurons in 1st layer: 2^(8 to 10) }, P30 = { learning rates: 5.0E-(1 to 5), optimizes: Adam, neurons in 1st layer: 2^9 }
- -o : Number of MLPs to train at a given time (after -s numberOfInstancesToTrainAllMLPsAtStart instances).
- -L : Number of layers in each MLP.
- -s : Number of instances to train all MLPs at start.
- -B : Mini Batch Size.
- -h : Use one hot encoding.
- -n : Normalize data.
- -b : Skip back propagation loss threshold.
- -d : Choose device to run the model(For GPU, needs CUDA installed on the system. Use CPU if GPUs are not available)
- -t : Do NOT train each MLP using a separate thread.
- -f : Votes dump file name.
- -F : Stats dump file name.
- Version:
- $Revision: 1 $
- Author:
- Nuwan Gunasekara (ng98 at students dot waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description FloatOption
backPropLossThreshold
MultiChoiceOption
deviceTypeOption
IntOption
djlRandomSeed
FlagOption
doNotTrainEachMLPUsingASeparateThread
protected int
featureValuesArraySize
static int
LARGER_P_POOL_10
static int
LARGER_P_POOL_30
MultiChoiceOption
largerPool
IntOption
miniBatchSize
protected MLP[]
nn
protected MLP.NormalizeInfo[]
normalizeInfo
IntOption
numberOfInstancesToTrainAllMLPsAtStartOption
IntOption
numberOfLayersInEachMLP
IntOption
numberOfMLPsToTrainOption
protected long
samplesSeen
StringOption
statsDumpFileName
FlagOption
useNormalization
FlagOption
useOneHotEncode
StringOption
votesDumpFileName
-
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 CAND()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableCapabilities
defineImmutableCapabilities()
Defines the set of capabilities the object has.void
getModelDescription(StringBuilder arg0, int arg1)
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.double[]
getVotesForInstance(Instance instance)
Predicts the class memberships for a given instance.protected void
initNNs(Instance instance)
boolean
isRandomizable()
Gets whether this learner needs a random seed.void
resetLearningImpl()
Resets this classifier.void
trainOnInstanceImpl(Instance instance)
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.-
Methods inherited from class moa.classifiers.AbstractClassifier
contextIsCompatible, copy, correctlyClassifies, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getPurposeString, 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
-
nn
protected MLP[] nn
-
featureValuesArraySize
protected int featureValuesArraySize
-
samplesSeen
protected long samplesSeen
-
normalizeInfo
protected MLP.NormalizeInfo[] normalizeInfo
-
LARGER_P_POOL_10
public static final int LARGER_P_POOL_10
- See Also:
- Constant Field Values
-
LARGER_P_POOL_30
public static final int LARGER_P_POOL_30
- See Also:
- Constant Field Values
-
largerPool
public MultiChoiceOption largerPool
-
numberOfMLPsToTrainOption
public IntOption numberOfMLPsToTrainOption
-
numberOfLayersInEachMLP
public IntOption numberOfLayersInEachMLP
-
numberOfInstancesToTrainAllMLPsAtStartOption
public IntOption numberOfInstancesToTrainAllMLPsAtStartOption
-
miniBatchSize
public IntOption miniBatchSize
-
useOneHotEncode
public FlagOption useOneHotEncode
-
useNormalization
public FlagOption useNormalization
-
backPropLossThreshold
public FloatOption backPropLossThreshold
-
deviceTypeOption
public MultiChoiceOption deviceTypeOption
-
doNotTrainEachMLPUsingASeparateThread
public FlagOption doNotTrainEachMLPUsingASeparateThread
-
votesDumpFileName
public StringOption votesDumpFileName
-
statsDumpFileName
public StringOption statsDumpFileName
-
djlRandomSeed
public IntOption djlRandomSeed
-
-
Method Detail
-
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
-
trainOnInstanceImpl
public void trainOnInstanceImpl(Instance instance)
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:
instance
- the instance to be used for training
-
getVotesForInstance
public double[] getVotesForInstance(Instance instance)
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:
instance
- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class
-
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.
-
getModelDescription
public void getModelDescription(StringBuilder arg0, int arg1)
Description copied from class:AbstractClassifier
Returns a string representation of the model.- Specified by:
getModelDescription
in classAbstractClassifier
- Parameters:
arg0
- the stringbuilder to add the descriptionarg1
- the number of characters to indent
-
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
-
initNNs
protected void initNNs(Instance instance)
-
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.
-
-