Logo ROOT   6.12/07
Reference Guide
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
TMVA::DNN::Net Class Reference

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 1068 of file NeuralNet.h.

Public Types

typedef std::pair< iterator_type, iterator_typebegin_end_type
 
typedef std::vector< double > container_type
 
typedef container_type::iterator iterator_type
 

Public Member Functions

 Net ()
 c'tor More...
 
 Net (const Net &other)
 d'tor More...
 
void addLayer (Layer &layer)
 add a layer (layout) More...
 
void addLayer (Layer &&layer)
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
size_t inputSize () const
 input size of the DNN More...
 
const std::vector< Layer > & layers () const
 returns the layers (structure) More...
 
std::vector< Layer > & layers ()
 returns the layers (structure) More...
 
size_t numNodes (size_t trainingStartLayer=0) const
 returns the number of nodes in this net More...
 
size_t numWeights (size_t trainingStartLayer=0) const
 returns the number of weights in this net More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
void removeLayer ()
 remove one layer More...
 
void setErrorFunction (ModeErrorFunction eErrorFunction)
 which error function is to be used More...
 
void setInputSize (size_t sizeInput)
 set the input size of the DNN More...
 
void SetIpythonInteractive (IPythonInteractive *fI, bool *fE, UInt_t *M, UInt_t *C)
 
void setOutputSize (size_t sizeOutput)
 set the output size of the DNN More...
 
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 More...
 
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 More...
 

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) More...
 

Protected Attributes

bool * fExitFromTraining = nullptr
 
IPythonInteractivefInteractive = nullptr
 
UInt_tfIPyCurrentIter = nullptr
 
UInt_tfIPyMaxIter = nullptr
 

Private Attributes

ModeErrorFunction m_eErrorFunction
 denotes the error function More...
 
std::vector< Layerm_layers
 layer-structure-data More...
 
size_t m_sizeInput
 input size of this DNN More...
 
size_t m_sizeOutput
 outut size of this DNN More...
 

#include <TMVA/NeuralNet.h>

Member Typedef Documentation

◆ begin_end_type

typedef std::pair<iterator_type,iterator_type> TMVA::DNN::Net::begin_end_type

Definition at line 1074 of file NeuralNet.h.

◆ container_type

typedef std::vector<double> TMVA::DNN::Net::container_type

Definition at line 1072 of file NeuralNet.h.

◆ iterator_type

typedef container_type::iterator TMVA::DNN::Net::iterator_type

Definition at line 1073 of file NeuralNet.h.

Constructor & Destructor Documentation

◆ Net() [1/2]

TMVA::DNN::Net::Net ( )
inline

c'tor

Definition at line 1081 of file NeuralNet.h.

◆ Net() [2/2]

TMVA::DNN::Net::Net ( const Net other)
inline

d'tor

Definition at line 1092 of file NeuralNet.h.

Member Function Documentation

◆ addLayer() [1/2]

void TMVA::DNN::Net::addLayer ( Layer layer)
inline

add a layer (layout)

Definition at line 1101 of file NeuralNet.h.

◆ addLayer() [2/2]

void TMVA::DNN::Net::addLayer ( Layer &&  layer)
inline

Definition at line 1102 of file NeuralNet.h.

◆ backPropagate()

template<typename Settings >
void TMVA::DNN::Net::backPropagate ( std::vector< std::vector< LayerData >> &  layerPatternData,
const Settings settings,
size_t  trainFromLayer,
size_t  totalNumWeights 
) const

Definition at line 1366 of file NeuralNet.icc.

◆ clear()

void TMVA::DNN::Net::clear ( )
inline

Definition at line 1258 of file NeuralNet.h.

◆ compute()

template<typename Weights >
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

Parameters
inputthe input data
weightsthe weight data

Definition at line 1038 of file NeuralNet.icc.

◆ computeError()

template<typename ItWeight >
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 1329 of file NeuralNet.icc.

◆ dE()

void TMVA::DNN::Net::dE ( )

◆ dropOutWeightFactor()

template<typename WeightsType , typename DropProbabilities >
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 651 of file NeuralNet.icc.

◆ E()

double TMVA::DNN::Net::E ( )

◆ errorFunction()

template<typename Container , typename ItWeight >
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 1591 of file NeuralNet.icc.

◆ fetchOutput() [1/2]

template<typename OutputContainer >
void TMVA::DNN::Net::fetchOutput ( const LayerData lastLayerData,
OutputContainer &  outputContainer 
) const

Definition at line 1299 of file NeuralNet.icc.

◆ fetchOutput() [2/2]

template<typename OutputContainer >
void TMVA::DNN::Net::fetchOutput ( const std::vector< LayerData > &  layerPatternData,
OutputContainer &  outputContainer 
) const

Definition at line 1320 of file NeuralNet.icc.

◆ fillDropContainer()

void TMVA::DNN::Net::fillDropContainer ( DropContainer dropContainer,
double  dropFraction,
size_t  _numNodes 
) const
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 554 of file NeuralNet.cxx.

◆ forward_backward()

template<typename LayerContainer , typename PassThrough , typename ItWeight , typename ItGradient , typename OutContainer >
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 1417 of file NeuralNet.icc.

◆ forwardBatch()

template<typename LayerContainer , typename LayerPatternContainer >
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 1244 of file NeuralNet.icc.

◆ forwardPattern()

template<typename LayerContainer >
void TMVA::DNN::Net::forwardPattern ( const LayerContainer &  _layers,
std::vector< LayerData > &  layerData 
) const

Definition at line 1224 of file NeuralNet.icc.

◆ initializeWeights()

template<typename OutIterator >
void TMVA::DNN::Net::initializeWeights ( WeightInitializationStrategy  eInitStrategy,
OutIterator  itWeight 
)

initialize the weights with the given strategy

initialization of the weights

Definition at line 1482 of file NeuralNet.icc.

◆ inputSize()

size_t TMVA::DNN::Net::inputSize ( ) const
inline

input size of the DNN

Definition at line 1105 of file NeuralNet.h.

◆ layers() [1/2]

const std::vector<Layer>& TMVA::DNN::Net::layers ( ) const
inline

returns the layers (structure)

Definition at line 1252 of file NeuralNet.h.

◆ layers() [2/2]

std::vector<Layer>& TMVA::DNN::Net::layers ( )
inline

returns the layers (structure)

Definition at line 1253 of file NeuralNet.h.

◆ numNodes()

size_t TMVA::DNN::Net::numNodes ( size_t  trainingStartLayer = 0) const

returns the number of nodes in this net

Definition at line 538 of file NeuralNet.cxx.

◆ numWeights()

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 522 of file NeuralNet.cxx.

◆ operator()() [1/4]

template<typename Weights , typename PassThrough >
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 1071 of file NeuralNet.icc.

◆ operator()() [2/4]

template<typename Weights , typename PassThrough , typename OutContainer >
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 1080 of file NeuralNet.icc.

◆ operator()() [3/4]

template<typename Weights , typename Gradients , typename PassThrough >
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 1090 of file NeuralNet.icc.

◆ operator()() [4/4]

template<typename Weights , typename Gradients , typename PassThrough , typename OutContainer >
double TMVA::DNN::Net::operator() ( PassThrough &  settingsAndBatch,
Weights &  weights,
Gradients &  gradients,
ModeOutput  eFetch,
OutContainer &  outputContainer 
) const

Definition at line 1100 of file NeuralNet.icc.

◆ outputSize()

size_t TMVA::DNN::Net::outputSize ( ) const
inline

output size of the DNN

Definition at line 1106 of file NeuralNet.h.

◆ prepareLayerData()

template<typename LayerContainer , typename DropContainer , typename ItWeight , typename ItGradient >
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 1112 of file NeuralNet.icc.

◆ preTrain()

template<typename Minimizer >
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

◆ removeLayer()

void TMVA::DNN::Net::removeLayer ( )
inline

remove one layer

Definition at line 1255 of file NeuralNet.h.

◆ setErrorFunction()

void TMVA::DNN::Net::setErrorFunction ( ModeErrorFunction  eErrorFunction)
inline

which error function is to be used

Definition at line 1103 of file NeuralNet.h.

◆ setInputSize()

void TMVA::DNN::Net::setInputSize ( size_t  sizeInput)
inline

set the input size of the DNN

Definition at line 1099 of file NeuralNet.h.

◆ SetIpythonInteractive()

void TMVA::DNN::Net::SetIpythonInteractive ( IPythonInteractive fI,
bool *  fE,
UInt_t M,
UInt_t C 
)
inline

Definition at line 1290 of file NeuralNet.h.

◆ setOutputSize()

void TMVA::DNN::Net::setOutputSize ( size_t  sizeOutput)
inline

set the output size of the DNN

Definition at line 1100 of file NeuralNet.h.

◆ train()

template<typename Minimizer >
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

Parameters
weightsweight vector
trainPatterntraining pattern
testPatterntest pattern
minimizeruse this minimizer for training (e.g. SGD)
settingssettings used for this training run
weightsthe container with the weights (synapses)
trainPatternthe pattern for the training
testPatternthe pattern for the testing
minimizerthe minimizer (e.g. steepest gradient descent) to be used
settingsthe settings for the training (e.g. multithreading or not, regularization etc.)

Definition at line 711 of file NeuralNet.icc.

◆ trainCycle()

template<typename Iterator , typename Minimizer >
double TMVA::DNN::Net::trainCycle ( Minimizer &  minimizer,
std::vector< double > &  weights,
Iterator  itPatternBegin,
Iterator  itPatternEnd,
Settings settings,
DropContainer dropContainer 
)
inline

executes one training cycle

execute a single training cycle

Parameters
minimizierthe minimizer to be used
weightsthe weight vector to be used
itPatternBeginthe pattern to be trained with
itPatternEndthe pattern to be trainied with
settingsthe settings for the training
dropContainerthe configuration for DNN drop-out

uses multithreading if turned on

Parameters
minimizerthe minimizer to be used (e.g. SGD)
weightsthe weight container with all the synapse weights
itPatternBeginbegin of the pattern container itPatternEnd the end of the pattern container
settingsthe settings for this training (e.g. multithreading or not, regularization, etc.)
dropContainerthe data for dropping-out nodes (regularization technique)

Definition at line 940 of file NeuralNet.icc.

Member Data Documentation

◆ fExitFromTraining

bool* TMVA::DNN::Net::fExitFromTraining = nullptr
protected

Definition at line 1284 of file NeuralNet.h.

◆ fInteractive

IPythonInteractive* TMVA::DNN::Net::fInteractive = nullptr
protected

Definition at line 1283 of file NeuralNet.h.

◆ fIPyCurrentIter

UInt_t * TMVA::DNN::Net::fIPyCurrentIter = nullptr
protected

Definition at line 1285 of file NeuralNet.h.

◆ fIPyMaxIter

UInt_t* TMVA::DNN::Net::fIPyMaxIter = nullptr
protected

Definition at line 1285 of file NeuralNet.h.

◆ m_eErrorFunction

ModeErrorFunction TMVA::DNN::Net::m_eErrorFunction
private

denotes the error function

Definition at line 1276 of file NeuralNet.h.

◆ m_layers

std::vector<Layer> TMVA::DNN::Net::m_layers
private

layer-structure-data

Definition at line 1279 of file NeuralNet.h.

◆ m_sizeInput

size_t TMVA::DNN::Net::m_sizeInput
private

input size of this DNN

Definition at line 1277 of file NeuralNet.h.

◆ m_sizeOutput

size_t TMVA::DNN::Net::m_sizeOutput
private

outut size of this DNN

Definition at line 1278 of file NeuralNet.h.

Libraries for TMVA::DNN::Net:
[legend]

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