27 #ifndef GRT_MLP_HEADER 28 #define GRT_MLP_HEADER 31 #include "../../../CoreModules/Regressifier.h" 44 enum TrainingAlgorithm{ONLINE_GRADIENT_DESCENT=0};
69 MLP &operator=(
const MLP &rhs);
110 virtual bool clear();
117 virtual bool print()
const;
126 virtual bool save( std::fstream &file )
const;
135 virtual bool load( std::fstream &file );
144 UINT getNumClasses()
const;
161 bool init(
const UINT numInputNeurons,
const UINT numHiddenNeurons,
const UINT numOutputNeurons);
180 bool init(
const UINT numInputNeurons,
const UINT numHiddenNeurons,
const UINT numOutputNeurons,
181 const Neuron::Type inputLayerActivationFunction,
182 const Neuron::Type hiddenLayerActivationFunction,
183 const Neuron::Type outputLayerActivationFunction);
189 void printNetwork()
const;
196 bool checkForNAN()
const;
204 std::string activationFunctionToString(
const Neuron::Type activationFunction)
const;
212 Neuron::Type activationFunctionFromString(
const std::string activationName)
const;
220 bool validateActivationFunction(
const Neuron::Type avactivationFunction)
const;
227 UINT getNumInputNeurons()
const;
234 UINT getNumHiddenNeurons()
const;
241 UINT getNumOutputNeurons()
const;
251 UINT getNumRandomTrainingIterations()
const;
258 Neuron::Type getInputLayerActivationFunction()
const;
265 Neuron::Type getHiddenLayerActivationFunction()
const;
272 Neuron::Type getOutputLayerActivationFunction()
const;
279 Float getTrainingRate()
const;
286 Float getMomentum()
const;
293 Float getGamma()
const;
301 Float getTrainingError()
const;
308 bool getClassificationModeActive()
const;
315 bool getRegressionModeActive()
const;
351 bool getNullRejectionEnabled()
const;
360 Float getNullRejectionCoeff()
const;
369 Float getNullRejectionThreshold()
const;
379 Float getMaximumLikelihood()
const;
400 UINT getPredictedClassLabel()
const;
409 bool setInputLayerActivationFunction(
const Neuron::Type activationFunction);
418 bool setHiddenLayerActivationFunction(
const Neuron::Type activationFunction);
427 bool setOutputLayerActivationFunction(
const Neuron::Type activationFunction);
437 bool setTrainingRate(
const Float trainingRate);
446 bool setMomentum(
const Float momentum);
455 bool setGamma(
const Float gamma);
468 GRT_DEPRECATED_MSG(
"setNumRandomTrainingIterations() is deprecated, use setNumRestarts() instead",
bool setNumRandomTrainingIterations(
const UINT numRandomTrainingIterations));
476 bool setNullRejection(
const bool useNullRejection);
487 bool setNullRejectionCoeff(
const Float nullRejectionCoeff);
494 static std::string
getId();
505 bool inline isNAN(
const Float &v)
const;
507 bool setOutputTargets();
515 bool loadLegacyModelFromFile( std::fstream &file );
526 Float back_prop(
const VectorFloat &inputVector,
const VectorFloat &targetVector,
const Float alpha,
const Float beta);
546 UINT numInputNeurons;
547 UINT numHiddenNeurons;
548 UINT numOutputNeurons;
549 Neuron::Type inputLayerActivationFunction;
550 Neuron::Type hiddenLayerActivationFunction;
551 Neuron::Type outputLayerActivationFunction;
565 bool classificationModeActive;
566 bool useNullRejection;
567 UINT predictedClassLabel;
568 Float nullRejectionThreshold;
569 Float nullRejectionCoeff;
582 static const std::string id;
588 #endif //GRT_MLP_HEADER std::string getId() const
virtual bool predict(VectorFloat inputVector)
This class implements a Neuron that is used by the Multilayer Perceptron.
virtual bool predict_(VectorFloat &inputVector)
virtual bool clear() override
virtual bool train(ClassificationData trainingData)
virtual bool save(const std::string &filename) const
virtual bool deepCopyFrom(const Regressifier *regressifier)
virtual bool print() const
virtual bool train_(ClassificationData &trainingData)
virtual bool load(const std::string &filename)