14 #ifndef MLPACK_METHODS_ANN_LAYER_DROPCONNECT_HPP 15 #define MLPACK_METHODS_ANN_LAYER_DROPCONNECT_HPP 49 template<
typename MatType = arma::mat>
64 const double ratio = 0.5);
87 void Forward(
const MatType& input, MatType& output);
96 void Backward(
const MatType& input,
const MatType& gy, MatType& g);
105 void Gradient(
const MatType& input,
const MatType& error, MatType& gradient);
108 double Ratio()
const {
return ratio; }
114 scale = 1.0 / (1.0 - ratio);
121 size_t WeightSize()
const {
return baseLayer->WeightSize(); }
124 void SetWeights(
typename MatType::elem_type* weightsPtr);
129 template<
typename Archive>
130 void serialize(Archive& ar,
const uint32_t );
158 #include "dropconnect_impl.hpp" Linear algebra utility functions, generally performed on matrices or vectors.
void Ratio(const double r)
Modify the probability of setting a value to zero.
virtual ~DropConnectType()
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t WeightSize() const
Return the size of the weights.
void SetWeights(typename MatType::elem_type *weightsPtr)
Reset the layer parameter.
The DropConnect layer is a regularizer that randomly with probability ratio sets the connection value...
DropConnectType< arma::mat > DropConnect
void ComputeOutputDimensions()
Compute the output dimensions of the layer based on InputDimensions().
void Gradient(const MatType &input, const MatType &error, MatType &gradient)
Calculate the gradient using the output delta and the input activation.
void Forward(const MatType &input, MatType &output)
Ordinary feed forward pass of the DropConnect layer.
DropConnectType * Clone() const
Clone the DropConnectType object. This handles polymorphism correctly.
DropConnectType()
Create the DropConnect object.
A layer is an abstract class implementing common neural networks operations, such as convolution...
double Ratio() const
The probability of setting a value to zero.
void Backward(const MatType &input, const MatType &gy, MatType &g)
Ordinary feed backward pass of the DropConnect layer.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
DropConnectType & operator=(const DropConnectType &other)
Copy the given DropConnectType (except for weights).