Implementation of the constant layer. More...
Public Member Functions | |
ConstantType () | |
Create an empty Constant layer. More... | |
ConstantType (const size_t outSize, const double scalar=0) | |
Create the Constant object that outputs a given constant scalar value given any input value. More... | |
ConstantType (const ConstantType &layer) | |
Copy another ConstantType. More... | |
ConstantType (ConstantType &&layer) | |
Take ownership of another ConstantType. More... | |
void | Backward (const InputType &, const OutputType &, OutputType &g) |
Ordinary feed backward pass of a neural network. More... | |
ConstantType * | Clone () const |
Clone the ConstantType object. This handles polymorphism correctly. More... | |
void | Forward (const InputType &input, OutputType &output) |
Ordinary feed forward pass of a neural network. More... | |
ConstantType & | operator= (const ConstantType &layer) |
Copy another ConstantType. More... | |
ConstantType & | operator= (ConstantType &&layer) |
Take ownership of another ConstantType. More... | |
const std::vector< size_t > & | OutputDimensions () const |
Get the output size. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the layer. More... | |
![]() | |
Layer () | |
Default constructor. More... | |
Layer (const Layer &layer) | |
Copy constructor. This is not responsible for copying weights! More... | |
Layer (Layer &&layer) | |
Move constructor. This is not responsible for moving weights! More... | |
virtual | ~Layer () |
Default deconstructor. More... | |
virtual void | Backward (const InputType &, const InputType &, InputType &) |
Performs a backpropagation step through the layer, with respect to the given input. More... | |
virtual void | ComputeOutputDimensions () |
Compute the output dimensions. More... | |
virtual void | CustomInitialize (InputType &, const size_t) |
Override the weight matrix of the layer. More... | |
virtual void | Forward (const InputType &, InputType &) |
Takes an input object, and computes the corresponding output of the layer. More... | |
virtual void | Forward (const InputType &, const InputType &) |
Takes an input and output object, and computes the corresponding loss of the layer. More... | |
virtual void | Gradient (const InputType &, const InputType &, InputType &) |
Computing the gradient of the layer with respect to its own input. More... | |
const std::vector< size_t > & | InputDimensions () const |
Get the input dimensions. More... | |
std::vector< size_t > & | InputDimensions () |
Modify the input dimensions. More... | |
virtual double | Loss () |
Get the layer loss. More... | |
virtual Layer & | operator= (const Layer &layer) |
Copy assignment operator. This is not responsible for copying weights! More... | |
virtual Layer & | operator= (Layer &&layer) |
Move assignment operator. This is not responsible for moving weights! More... | |
const std::vector< size_t > & | OutputDimensions () |
Get the output dimensions. More... | |
virtual size_t | OutputSize () final |
Get the number of elements in the output from this layer. More... | |
virtual const InputType & | Parameters () const |
Get the parameters. More... | |
virtual InputType & | Parameters () |
Set the parameters. More... | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the layer. More... | |
virtual void | SetWeights (typename InputType ::elem_type *) |
Reset the layer parameter. More... | |
virtual bool const & | Training () const |
Get whether the layer is currently in training mode. More... | |
virtual bool & | Training () |
Modify whether the layer is currently in training mode. More... | |
virtual size_t | WeightSize () const |
Get the total number of trainable weights in the layer. More... | |
Additional Inherited Members | |
![]() | |
std::vector< size_t > | inputDimensions |
Logical input dimensions of each point. More... | |
std::vector< size_t > | outputDimensions |
Logical output dimensions of each point. More... | |
bool | training |
If true, the layer is in training mode; otherwise, it is in testing mode. More... | |
bool | validOutputDimensions |
This is true if ComputeOutputDimensions() has been called, and outputDimensions can be considered to be up-to-date. More... | |
Implementation of the constant layer.
The constant layer outputs a given constant value given any input value.
InputType | The type of the layer's inputs. The layer automatically cast inputs to this type (Default: arma::mat). |
OutputType | The type of the computation which also causes the output to also be in this type. The type also allows the computation and weight type to differ from the input type (Default: arma::mat). |
Definition at line 34 of file constant.hpp.
ConstantType | ( | ) |
Create an empty Constant layer.
Referenced by ConstantType< InputType, OutputType >::Clone().
ConstantType | ( | const size_t | outSize, |
const double | scalar = 0 |
||
) |
Create the Constant object that outputs a given constant scalar value given any input value.
outSize | The number of output units. |
scalar | The constant value used to create the constant output. |
ConstantType | ( | const ConstantType< InputType, OutputType > & | layer | ) |
Copy another ConstantType.
ConstantType | ( | ConstantType< InputType, OutputType > && | layer | ) |
Take ownership of another ConstantType.
void Backward | ( | const InputType & | , |
const OutputType & | , | ||
OutputType & | g | ||
) |
Ordinary feed backward pass of a neural network.
The backward pass of the constant layer is returns always a zero output error matrix.
* | (input) The propagated input activation. |
* | (gy) The backpropagated error. |
g | The calculated gradient. |
Referenced by ConstantType< InputType, OutputType >::Clone().
|
inlinevirtual |
Clone the ConstantType object. This handles polymorphism correctly.
Implements Layer< InputType, OutputType >.
Definition at line 61 of file constant.hpp.
References ConstantType< InputType, OutputType >::Backward(), ConstantType< InputType, OutputType >::ConstantType(), and ConstantType< InputType, OutputType >::Forward().
void Forward | ( | const InputType & | input, |
OutputType & | output | ||
) |
Ordinary feed forward pass of a neural network.
The forward pass fills the output with the specified constant parameter.
input | Input data used for evaluating the specified function. |
output | Resulting output activation. |
Referenced by ConstantType< InputType, OutputType >::Clone().
ConstantType& operator= | ( | const ConstantType< InputType, OutputType > & | layer | ) |
Copy another ConstantType.
ConstantType& operator= | ( | ConstantType< InputType, OutputType > && | layer | ) |
Take ownership of another ConstantType.
|
inline |
Get the output size.
Definition at line 85 of file constant.hpp.
References Layer< InputType, OutputType >::inputDimensions, and ConstantType< InputType, OutputType >::serialize().
void serialize | ( | Archive & | ar, |
const uint32_t | |||
) |
Serialize the layer.
Referenced by ConstantType< InputType, OutputType >::OutputDimensions().