Generic neural network class.
This generic neural network class represents a concrete neural network through a vector of layers and coordinates the forward and backward propagation through the net.
The net takes as input a batch from the training data given in matrix form, with each row corresponding to a certain training event.
On construction, the neural network allocates all the memory required for the training of the neural net and keeps it until its destruction.
The Architecture type argument simply holds the architecture-specific data types, which are just the matrix type Matrix_t and the used scalar type Scalar_t.
Architecture | The Architecture type that holds the |
Layer_t | The type used for the layers. Can be either Layer<Architecture> or SharedWeightLayer<Architecture>. datatypes for a given architecture. |
Public Types | |
using | LayerIterator_t = typename std::vector<Layer_t>::iterator |
using | Matrix_t = typename Architecture_t::Matrix_t |
using | Scalar_t = typename Architecture_t::Scalar_t |
Public Member Functions | |
TNet () | |
TNet (const TNet &other) | |
template<typename OtherArchitecture_t > | |
TNet (size_t batchSize, const TNet< OtherArchitecture_t > &) | |
TNet (size_t batchSize, size_t inputWidth, ELossFunction fJ, ERegularization fR=ERegularization::kNone, Scalar_t fWeightDecay=0.0) | |
Construct a neural net for a given batch size with given output function * and regularization. | |
template<typename SharedLayer > | |
void | AddLayer (SharedLayer &layer) |
Add a layer which shares its weights with another TNet instance. | |
template<typename SharedLayer_t > | |
void | AddLayer (SharedLayer_t &layer) |
void | AddLayer (size_t width, EActivationFunction f, Scalar_t dropoutProbability=1.0) |
Add a layer of the given size to the neural net. | |
void | Backward (const Matrix_t &X, const Matrix_t &Y, const Matrix_t &weights) |
Compute the weight gradients in the net from the given training samples X and training labels Y. | |
void | Clear () |
Remove all layers from the network. | |
TNet< Architecture_t, TSharedLayer< Architecture_t > > | CreateClone (size_t batchSize) |
Create a clone that uses the same weight and biases matrices but potentially a difference batch size. | |
void | Forward (Matrix_t &X, bool applyDropout=false) |
Forward a given input through the neural net. | |
size_t | GetBatchSize () const |
size_t | GetDepth () const |
size_t | GetInputWidth () const |
Layer_t & | GetLayer (size_t i) |
const Layer_t & | GetLayer (size_t i) const |
ELossFunction | GetLossFunction () const |
Scalar_t | GetNFlops () |
Matrix_t & | GetOutput () |
size_t | GetOutputWidth () const |
ERegularization | GetRegularization () const |
Scalar_t | GetWeightDecay () const |
void | Initialize (EInitialization m) |
Initialize the weights in the net with the initialization method. | |
void | InitializeGradients () |
Initialize the gradients in the net to zero. | |
LayerIterator_t | LayersBegin () |
Iterator to the first layer of the net. | |
LayerIterator_t | LayersEnd () |
Iterator to the last layer of the net. | |
Scalar_t | Loss (const Matrix_t &Y, const Matrix_t &weights, bool includeRegularization=true) const |
Evaluate the loss function of the net using the activations that are currently stored in the output layer. | |
Scalar_t | Loss (Matrix_t &X, const Matrix_t &Y, const Matrix_t &weights, bool applyDropout=false, bool includeRegularization=true) |
Propagate the input batch X through the net and evaluate the error function for the resulting activations of the output layer. | |
void | Prediction (Matrix_t &Y_hat, EOutputFunction f) const |
Compute the neural network prediction obtained from applying the output function f to the activation of the last layer in the network. | |
void | Prediction (Matrix_t &Y_hat, Matrix_t &X, EOutputFunction f) |
Compute the neural network prediction obtained from forwarding the batch X through the neural network and applying the output function f to the activation of the last layer in the network. | |
void | Print () |
void | SetBatchSize (size_t batchSize) |
void | SetDropoutProbabilities (const std::vector< Double_t > &probabilities) |
void | SetInputWidth (size_t inputWidth) |
void | SetLossFunction (ELossFunction J) |
void | SetRegularization (ERegularization R) |
void | SetWeightDecay (Scalar_t weightDecay) |
Private Attributes | |
size_t | fBatchSize |
Batch size for training and evaluation of the Network. | |
Matrix_t | fDummy |
Empty matrix for last step in back propagation. | |
size_t | fInputWidth |
Number of features in a single input event. | |
ELossFunction | fJ |
The loss function of the network. | |
std::vector< Layer_t > | fLayers |
Layers in the network. | |
ERegularization | fR |
The regularization used for the network. | |
Scalar_t | fWeightDecay |
The weight decay factor. | |
#include <TMVA/DNN/Net.h>
using TMVA::DNN::TNet< Architecture_t, Layer_t >::LayerIterator_t = typename std::vector<Layer_t>::iterator |
using TMVA::DNN::TNet< Architecture_t, Layer_t >::Matrix_t = typename Architecture_t::Matrix_t |
using TMVA::DNN::TNet< Architecture_t, Layer_t >::Scalar_t = typename Architecture_t::Scalar_t |
TMVA::DNN::TNet< Architecture_t, Layer_t >::TNet | ( | ) |
TMVA::DNN::TNet< Architecture_t, Layer_t >::TNet | ( | const TNet< Architecture_t, Layer_t > & | other | ) |
TMVA::DNN::TNet< Architecture_t, Layer_t >::TNet | ( | size_t | batchSize, |
const TNet< OtherArchitecture_t > & | other ) |
TMVA::DNN::TNet< Architecture_t, Layer_t >::TNet | ( | size_t | batchSize, |
size_t | inputWidth, | ||
ELossFunction | fJ, | ||
ERegularization | fR = ERegularization::kNone, | ||
Scalar_t | fWeightDecay = 0.0 ) |
void TMVA::DNN::TNet< Architecture_t, Layer_t >::AddLayer | ( | SharedLayer & | layer | ) |
Add a layer which shares its weights with another TNet instance.
|
inline |
void TMVA::DNN::TNet< Architecture_t, Layer_t >::AddLayer | ( | size_t | width, |
EActivationFunction | f, | ||
Scalar_t | dropoutProbability = 1.0 ) |
void TMVA::DNN::TNet< Architecture_t, Layer_t >::Clear | ( | ) |
auto TMVA::DNN::TNet< Architecture_t, Layer_t >::CreateClone | ( | size_t | batchSize | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
auto TMVA::DNN::TNet< Architecture_t, Layer_t >::GetNFlops | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void TMVA::DNN::TNet< Architecture_t, Layer_t >::Print | ( | ) |
|
inline |
void TMVA::DNN::TNet< Architecture_t, Layer_t >::SetDropoutProbabilities | ( | const std::vector< Double_t > & | probabilities | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |