neural net
holds the structure of all layers and some data for the whole net does not know the layer data though (i.e. values of the nodes and weights)
Definition at line 1061 of file NeuralNet.h.
Public Types | |
typedef std::pair< iterator_type, iterator_type > | begin_end_type |
typedef std::vector< double > | container_type |
typedef container_type::iterator | iterator_type |
Public Member Functions | |
Net () | |
c'tor | |
Net (const Net &other) | |
d'tor | |
void | addLayer (Layer &&layer) |
void | addLayer (Layer &layer) |
add a layer (layout) | |
template<typename Settings > | |
void | backPropagate (std::vector< std::vector< LayerData > > &layerPatternData, const Settings &settings, size_t trainFromLayer, size_t totalNumWeights) const |
void | clear () |
template<typename Weights > | |
std::vector< double > | compute (const std::vector< double > &input, const Weights &weights) const |
compute the net with the given input and the given weights | |
template<typename ItWeight > | |
std::tuple< double, double > | computeError (const Settings &settings, std::vector< LayerData > &lastLayerData, Batch &batch, ItWeight itWeightBegin, ItWeight itWeightEnd) const |
void | dE () |
template<typename WeightsType , typename DropProbabilities > | |
void | dropOutWeightFactor (WeightsType &weights, const DropProbabilities &drops, bool inverse=false) |
set the drop out configuration | |
double | E () |
template<typename Container , typename ItWeight > | |
double | errorFunction (LayerData &layerData, Container truth, ItWeight itWeight, ItWeight itWeightEnd, double patternWeight, double factorWeightDecay, EnumRegularization eRegularization) const |
computes the error of the DNN | |
template<typename OutputContainer > | |
void | fetchOutput (const LayerData &lastLayerData, OutputContainer &outputContainer) const |
template<typename OutputContainer > | |
void | fetchOutput (const std::vector< LayerData > &layerPatternData, OutputContainer &outputContainer) const |
template<typename LayerContainer , typename PassThrough , typename ItWeight , typename ItGradient , typename OutContainer > | |
double | forward_backward (LayerContainer &layers, PassThrough &settingsAndBatch, ItWeight itWeightBegin, ItWeight itWeightEnd, ItGradient itGradientBegin, ItGradient itGradientEnd, size_t trainFromLayer, OutContainer &outputContainer, bool fetchOutput) const |
main NN computation function | |
template<typename LayerContainer , typename LayerPatternContainer > | |
void | forwardBatch (const LayerContainer &_layers, LayerPatternContainer &layerPatternData, std::vector< double > &valuesMean, std::vector< double > &valuesStdDev, size_t trainFromLayer) const |
template<typename LayerContainer > | |
void | forwardPattern (const LayerContainer &_layers, std::vector< LayerData > &layerData) const |
template<typename OutIterator > | |
void | initializeWeights (WeightInitializationStrategy eInitStrategy, OutIterator itWeight) |
initialize the weights with the given strategy | |
size_t | inputSize () const |
input size of the DNN | |
std::vector< Layer > & | layers () |
returns the layers (structure) | |
const std::vector< Layer > & | layers () const |
returns the layers (structure) | |
size_t | numNodes (size_t trainingStartLayer=0) const |
returns the number of nodes in this net | |
size_t | numWeights (size_t trainingStartLayer=0) const |
returns the number of weights in this net | |
template<typename Weights , typename PassThrough > | |
double | operator() (PassThrough &settingsAndBatch, const Weights &weights) const |
execute computation of the DNN for one mini-batch (used by the minimizer); no computation of gradients | |
template<typename Weights , typename PassThrough , typename OutContainer > | |
double | operator() (PassThrough &settingsAndBatch, const Weights &weights, ModeOutput eFetch, OutContainer &outputContainer) const |
execute computation of the DNN for one mini-batch; helper function | |
template<typename Weights , typename Gradients , typename PassThrough > | |
double | operator() (PassThrough &settingsAndBatch, Weights &weights, Gradients &gradients) const |
execute computation of the DNN for one mini-batch (used by the minimizer); returns gradients as well | |
template<typename Weights , typename Gradients , typename PassThrough , typename OutContainer > | |
double | operator() (PassThrough &settingsAndBatch, Weights &weights, Gradients &gradients, ModeOutput eFetch, OutContainer &outputContainer) const |
size_t | outputSize () const |
output size of the DNN | |
template<typename LayerContainer , typename DropContainer , typename ItWeight , typename ItGradient > | |
std::vector< std::vector< LayerData > > | prepareLayerData (LayerContainer &layers, Batch &batch, const DropContainer &dropContainer, ItWeight itWeightBegin, ItWeight itWeightEnd, ItGradient itGradientBegin, ItGradient itGradientEnd, size_t &totalNumWeights) const |
template<typename Minimizer > | |
void | preTrain (std::vector< double > &weights, std::vector< Pattern > &trainPattern, const std::vector< Pattern > &testPattern, Minimizer &minimizer, Settings &settings) |
pre-training for future use | |
void | removeLayer () |
remove one layer | |
void | setErrorFunction (ModeErrorFunction eErrorFunction) |
which error function is to be used | |
void | setInputSize (size_t sizeInput) |
set the input size of the DNN | |
void | SetIpythonInteractive (IPythonInteractive *fI, bool *fE, UInt_t *M, UInt_t *C) |
void | setOutputSize (size_t sizeOutput) |
set the output size of the DNN | |
template<typename Minimizer > | |
double | train (std::vector< double > &weights, std::vector< Pattern > &trainPattern, const std::vector< Pattern > &testPattern, Minimizer &minimizer, Settings &settings) |
start the training | |
template<typename Iterator , typename Minimizer > | |
double | trainCycle (Minimizer &minimizer, std::vector< double > &weights, Iterator itPatternBegin, Iterator itPatternEnd, Settings &settings, DropContainer &dropContainer) |
executes one training cycle | |
Protected Member Functions | |
void | fillDropContainer (DropContainer &dropContainer, double dropFraction, size_t numNodes) const |
prepare the drop-out-container (select the nodes which are to be dropped out) | |
Protected Attributes | |
bool * | fExitFromTraining = nullptr |
IPythonInteractive * | fInteractive = nullptr |
UInt_t * | fIPyCurrentIter = nullptr |
UInt_t * | fIPyMaxIter = nullptr |
Private Attributes | |
ModeErrorFunction | m_eErrorFunction |
denotes the error function | |
std::vector< Layer > | m_layers |
layer-structure-data | |
size_t | m_sizeInput |
input size of this DNN | |
size_t | m_sizeOutput |
outut size of this DNN | |
#include <TMVA/NeuralNet.h>
typedef std::pair<iterator_type,iterator_type> TMVA::DNN::Net::begin_end_type |
Definition at line 1067 of file NeuralNet.h.
typedef std::vector<double> TMVA::DNN::Net::container_type |
Definition at line 1065 of file NeuralNet.h.
typedef container_type::iterator TMVA::DNN::Net::iterator_type |
Definition at line 1066 of file NeuralNet.h.
|
inline |
c'tor
Definition at line 1074 of file NeuralNet.h.
|
inline |
d'tor
Definition at line 1085 of file NeuralNet.h.
Definition at line 1095 of file NeuralNet.h.
add a layer (layout)
Definition at line 1094 of file NeuralNet.h.
void TMVA::DNN::Net::backPropagate | ( | std::vector< std::vector< LayerData > > & | layerPatternData, |
const Settings & | settings, | ||
size_t | trainFromLayer, | ||
size_t | totalNumWeights | ||
) | const |
Definition at line 1358 of file NeuralNet.icc.
|
inline |
Definition at line 1251 of file NeuralNet.h.
std::vector< double > TMVA::DNN::Net::compute | ( | const std::vector< double > & | input, |
const Weights & | weights | ||
) | const |
compute the net with the given input and the given weights
compute the neural net
input | the input data |
weights | the weight data |
Definition at line 1037 of file NeuralNet.icc.
std::tuple< double, double > TMVA::DNN::Net::computeError | ( | const Settings & | settings, |
std::vector< LayerData > & | lastLayerData, | ||
Batch & | batch, | ||
ItWeight | itWeightBegin, | ||
ItWeight | itWeightEnd | ||
) | const |
Definition at line 1321 of file NeuralNet.icc.
void TMVA::DNN::Net::dE | ( | ) |
void TMVA::DNN::Net::dropOutWeightFactor | ( | WeightsType & | weights, |
const DropProbabilities & | drops, | ||
bool | inverse = false |
||
) |
set the drop out configuration
compute the drop-out-weight factor
when using drop-out a fraction of the nodes is turned off at each cycle of the computation once all nodes are turned on again (for instances when the test samples are evaluated), the weights have to be adjusted to account for the different number of active nodes this function computes the factor and applies it to the weights
Definition at line 652 of file NeuralNet.icc.
double TMVA::DNN::Net::E | ( | ) |
double TMVA::DNN::Net::errorFunction | ( | LayerData & | layerData, |
Container | truth, | ||
ItWeight | itWeight, | ||
ItWeight | itWeightEnd, | ||
double | patternWeight, | ||
double | factorWeightDecay, | ||
EnumRegularization | eRegularization | ||
) | const |
computes the error of the DNN
compute the error function
Definition at line 1583 of file NeuralNet.icc.
void TMVA::DNN::Net::fetchOutput | ( | const LayerData & | lastLayerData, |
OutputContainer & | outputContainer | ||
) | const |
Definition at line 1291 of file NeuralNet.icc.
void TMVA::DNN::Net::fetchOutput | ( | const std::vector< LayerData > & | layerPatternData, |
OutputContainer & | outputContainer | ||
) | const |
Definition at line 1312 of file NeuralNet.icc.
|
protected |
prepare the drop-out-container (select the nodes which are to be dropped out)
prepare the drop-out container given the provided drop-fractions
Definition at line 575 of file NeuralNet.cxx.
double TMVA::DNN::Net::forward_backward | ( | LayerContainer & | _layers, |
PassThrough & | settingsAndBatch, | ||
ItWeight | itWeightBegin, | ||
ItWeight | itWeightEnd, | ||
ItGradient | itGradientBegin, | ||
ItGradient | itGradientEnd, | ||
size_t | trainFromLayer, | ||
OutContainer & | outputContainer, | ||
bool | doFetchOutput | ||
) | const |
main NN computation function
forward propagation and backward propagation
Definition at line 1409 of file NeuralNet.icc.
void TMVA::DNN::Net::forwardBatch | ( | const LayerContainer & | _layers, |
LayerPatternContainer & | layerPatternData, | ||
std::vector< double > & | valuesMean, | ||
std::vector< double > & | valuesStdDev, | ||
size_t | trainFromLayer | ||
) | const |
Definition at line 1240 of file NeuralNet.icc.
void TMVA::DNN::Net::forwardPattern | ( | const LayerContainer & | _layers, |
std::vector< LayerData > & | layerData | ||
) | const |
Definition at line 1221 of file NeuralNet.icc.
void TMVA::DNN::Net::initializeWeights | ( | WeightInitializationStrategy | eInitStrategy, |
OutIterator | itWeight | ||
) |
initialize the weights with the given strategy
initialization of the weights
Definition at line 1474 of file NeuralNet.icc.
|
inline |
input size of the DNN
Definition at line 1098 of file NeuralNet.h.
|
inline |
returns the layers (structure)
Definition at line 1246 of file NeuralNet.h.
|
inline |
returns the layers (structure)
Definition at line 1245 of file NeuralNet.h.
size_t TMVA::DNN::Net::numNodes | ( | size_t | trainingStartLayer = 0 | ) | const |
returns the number of nodes in this net
Definition at line 559 of file NeuralNet.cxx.
size_t TMVA::DNN::Net::numWeights | ( | size_t | trainingStartLayer = 0 | ) | const |
returns the number of weights in this net
compute the number of weights given the size of the input layer
Definition at line 543 of file NeuralNet.cxx.
double TMVA::DNN::Net::operator() | ( | PassThrough & | settingsAndBatch, |
const Weights & | weights | ||
) | const |
execute computation of the DNN for one mini-batch (used by the minimizer); no computation of gradients
Definition at line 1070 of file NeuralNet.icc.
double TMVA::DNN::Net::operator() | ( | PassThrough & | settingsAndBatch, |
const Weights & | weights, | ||
ModeOutput | eFetch, | ||
OutContainer & | outputContainer | ||
) | const |
execute computation of the DNN for one mini-batch; helper function
Definition at line 1079 of file NeuralNet.icc.
double TMVA::DNN::Net::operator() | ( | PassThrough & | settingsAndBatch, |
Weights & | weights, | ||
Gradients & | gradients | ||
) | const |
execute computation of the DNN for one mini-batch (used by the minimizer); returns gradients as well
Definition at line 1089 of file NeuralNet.icc.
double TMVA::DNN::Net::operator() | ( | PassThrough & | settingsAndBatch, |
Weights & | weights, | ||
Gradients & | gradients, | ||
ModeOutput | eFetch, | ||
OutContainer & | outputContainer | ||
) | const |
Definition at line 1099 of file NeuralNet.icc.
|
inline |
output size of the DNN
Definition at line 1099 of file NeuralNet.h.
std::vector< std::vector< LayerData > > TMVA::DNN::Net::prepareLayerData | ( | LayerContainer & | layers, |
Batch & | batch, | ||
const DropContainer & | dropContainer, | ||
ItWeight | itWeightBegin, | ||
ItWeight | itWeightEnd, | ||
ItGradient | itGradientBegin, | ||
ItGradient | itGradientEnd, | ||
size_t & | totalNumWeights | ||
) | const |
Definition at line 1111 of file NeuralNet.icc.
void TMVA::DNN::Net::preTrain | ( | std::vector< double > & | weights, |
std::vector< Pattern > & | trainPattern, | ||
const std::vector< Pattern > & | testPattern, | ||
Minimizer & | minimizer, | ||
Settings & | settings | ||
) |
pre-training for future use
|
inline |
remove one layer
Definition at line 1248 of file NeuralNet.h.
|
inline |
which error function is to be used
Definition at line 1096 of file NeuralNet.h.
|
inline |
set the input size of the DNN
Definition at line 1092 of file NeuralNet.h.
|
inline |
Definition at line 1283 of file NeuralNet.h.
|
inline |
set the output size of the DNN
Definition at line 1093 of file NeuralNet.h.
double TMVA::DNN::Net::train | ( | std::vector< double > & | weights, |
std::vector< Pattern > & | trainPattern, | ||
const std::vector< Pattern > & | testPattern, | ||
Minimizer & | minimizer, | ||
Settings & | settings | ||
) |
start the training
execute the training until convergence emerges
weights | weight vector |
trainPattern | training pattern |
testPattern | test pattern |
minimizer | use this minimizer for training (e.g. SGD) |
settings | settings used for this training run |
weights | the container with the weights (synapses) |
trainPattern | the pattern for the training |
testPattern | the pattern for the testing |
minimizer | the minimizer (e.g. steepest gradient descent) to be used |
settings | the settings for the training (e.g. multithreading or not, regularization etc.) |
Definition at line 712 of file NeuralNet.icc.
|
inline |
executes one training cycle
execute a single training cycle
minimizer | the minimizer to be used |
weights | the weight vector to be used |
itPatternBegin | the pattern to be trained with |
itPatternEnd | the pattern to be trainied with |
settings | the settings for the training |
dropContainer | the configuration for DNN drop-out |
uses multithreading if turned on
minimizer | the minimizer to be used (e.g. SGD) |
weights | the weight container with all the synapse weights |
itPatternBegin | begin of the pattern container |
itPatternEnd | the end of the pattern container |
settings | the settings for this training (e.g. multithreading or not, regularization, etc.) |
dropContainer | the data for dropping-out nodes (regularization technique) |
Definition at line 939 of file NeuralNet.icc.
|
protected |
Definition at line 1277 of file NeuralNet.h.
|
protected |
Definition at line 1276 of file NeuralNet.h.
|
protected |
Definition at line 1278 of file NeuralNet.h.
|
protected |
Definition at line 1278 of file NeuralNet.h.
|
private |
denotes the error function
Definition at line 1269 of file NeuralNet.h.
|
private |
layer-structure-data
Definition at line 1272 of file NeuralNet.h.
|
private |
input size of this DNN
Definition at line 1270 of file NeuralNet.h.
|
private |
outut size of this DNN
Definition at line 1271 of file NeuralNet.h.