RapidLib  v2.2.0
A simple library for interactive machine learning
neuralNetwork< T > Class Template Referencefinal

#include <neuralNetwork.h>

Inheritance diagram for neuralNetwork< T >:
Inheritance graph
Collaboration diagram for neuralNetwork< T >:
Collaboration graph

Public Member Functions

 neuralNetwork (const size_t &num_inputs, const std::vector< size_t > &which_inputs, const size_t &num_hidden_layers, const size_t &num_hidden_nodes, const std::vector< T > &weights, const std::vector< T > &wHiddenOutput, const std::vector< T > &inRanges, const std::vector< T > &inBases, const T &outRange, const T &outBase)
 
 neuralNetwork (const size_t &num_inputs, const std::vector< size_t > &which_inputs, const size_t &num_hidden_layer, const size_t &num_hidden_nodes)
 
 ~neuralNetwork ()
 
run (const std::vector< T > &inputVector) override
 
void reset () override
 
size_t getNumInputs () const override
 
std::vector< size_t > getWhichInputs () const override
 
size_t getNumHiddenLayers () const
 
void setNumHiddenLayers (size_t num_hidden_layers)
 
size_t getNumHiddenNodes () const
 
void setNumHiddenNodes (size_t num_hidden_nodes)
 
size_t getEpochs () const
 
void setEpochs (const size_t &epochs)
 
std::vector< T > getWeights () const
 
std::vector< T > getWHiddenOutput () const
 
std::vector< T > getInRanges () const
 
std::vector< T > getInBases () const
 
getOutRange () const
 
getOutBase () const
 
void getJSONDescription (Json::Value &currentModel) override
 
void train (const std::vector< trainingExampleTemplate< T > > &trainingSet) override
 These pertain to the training, and aren't need to run a trained model //. More...
 
void train (const std::vector< trainingExampleTemplate< T > > &trainingSet, const std::size_t whichOutput) override
 
size_t getCurrentEpoch () const
 
- Public Member Functions inherited from baseModel< T >
virtual ~baseModel ()
 

Additional Inherited Members

- Protected Member Functions inherited from baseModel< T >
template<typename TT , class Dummy = int>
Json::Value vector2json (TT vec)
 
template<class Dummy = int>
Json::Value vector2json (std::vector< unsigned long > vec)
 

Detailed Description

template<typename T>
class neuralNetwork< T >

Class for implementing a Neural Network.

This class includes both running and training, and constructors for reading trained models from JSON.

Constructor & Destructor Documentation

◆ neuralNetwork() [1/2]

template<typename T >
neuralNetwork< T >::neuralNetwork ( const size_t &  num_inputs,
const std::vector< size_t > &  which_inputs,
const size_t &  num_hidden_layers,
const size_t &  num_hidden_nodes,
const std::vector< T > &  _weights,
const std::vector< T > &  w_hidden_output,
const std::vector< T > &  in_ranges,
const std::vector< T > &  in_bases,
const T &  out_range,
const T &  out_base 
)

This is the constructor for building a trained model from JSON.

This is the constructor for a model imported from JSON.

◆ neuralNetwork() [2/2]

template<typename T >
neuralNetwork< T >::neuralNetwork ( const size_t &  num_inputs,
const std::vector< size_t > &  which_inputs,
const size_t &  num_hidden_layers,
const size_t &  num_hidden_nodes 
)

This constructor creates a neural network that needs to be trained.

Parameters
num_inputsis the number of inputs the network will process
which_inputsis an vector of which values in the input vector are being fed to the network. ex: {0,2,4}
num_hidden_layeris the number of hidden layers in the network. Must be at least 1.
num_hidden_nodesis the number of hidden nodes in each hidden layer. Often, this is the same as num_inputs
Returns
A neuralNetwork instance with randomized weights and no normalization values. These will be set or adjusted during training.

This is the constructor for a model that needs to be trained.

◆ ~neuralNetwork()

template<typename T >
neuralNetwork< T >::~neuralNetwork

destructor

This destructor is not needed.

Member Function Documentation

◆ getCurrentEpoch()

template<typename T >
size_t neuralNetwork< T >::getCurrentEpoch

Returns current training epoch.

◆ getEpochs()

template<typename T >
size_t neuralNetwork< T >::getEpochs

◆ getInBases()

template<typename T >
std::vector< T > neuralNetwork< T >::getInBases

◆ getInRanges()

template<typename T >
std::vector< T > neuralNetwork< T >::getInRanges

◆ getJSONDescription()

template<typename T >
void neuralNetwork< T >::getJSONDescription ( Json::Value &  currentModel)
overridevirtual

Implements baseModel< T >.

◆ getNumHiddenLayers()

template<typename T >
size_t neuralNetwork< T >::getNumHiddenLayers

◆ getNumHiddenNodes()

template<typename T >
size_t neuralNetwork< T >::getNumHiddenNodes

◆ getNumInputs()

template<typename T >
size_t neuralNetwork< T >::getNumInputs
overridevirtual

Implements baseModel< T >.

◆ getOutBase()

template<typename T >
T neuralNetwork< T >::getOutBase

◆ getOutRange()

template<typename T >
T neuralNetwork< T >::getOutRange

◆ getWeights()

template<typename T >
std::vector< T > neuralNetwork< T >::getWeights

◆ getWhichInputs()

template<typename T >
std::vector< size_t > neuralNetwork< T >::getWhichInputs
overridevirtual

Implements baseModel< T >.

◆ getWHiddenOutput()

template<typename T >
std::vector< T > neuralNetwork< T >::getWHiddenOutput

◆ reset()

template<typename T >
void neuralNetwork< T >::reset
overridevirtual

Implements baseModel< T >.

◆ run()

template<typename T >
T neuralNetwork< T >::run ( const std::vector< T > &  inputVector)
overridevirtual

Generate an output value from a single input vector.

Parameters
vectorA standard vector of type T that feed-forward regression will run on.
Returns
T A single value, which is the result of the feed-forward operation

Implements baseModel< T >.

◆ setEpochs()

template<typename T >
void neuralNetwork< T >::setEpochs ( const size_t &  epochs)

◆ setNumHiddenLayers()

template<typename T >
void neuralNetwork< T >::setNumHiddenLayers ( size_t  num_hidden_layers)

◆ setNumHiddenNodes()

template<typename T >
void neuralNetwork< T >::setNumHiddenNodes ( size_t  num_hidden_nodes)

◆ train() [1/2]

template<typename T >
void neuralNetwork< T >::train ( const std::vector< trainingExampleTemplate< T > > &  trainingSet)
overridevirtual

These pertain to the training, and aren't need to run a trained model //.

Train a model using backpropagation.

Parameters
Thetraining set is a vector of training examples that contain both a vector of input values and a value specifying desired output.

Implements baseModel< T >.

◆ train() [2/2]

template<typename T >
void neuralNetwork< T >::train ( const std::vector< trainingExampleTemplate< T > > &  trainingSet,
const std::size_t  whichOutput 
)
overridevirtual

Train a model using backpropagation. This function is used when the model is part of a modelSet.

Parameters
Thistriaining function takes examples that contain a vector of input values and a vector of output values.
Thesecond argument specifies which output this model is using.

Implements baseModel< T >.


The documentation for this class was generated from the following files: