mlpack 3.4.2
vr_class_reward.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_METHODS_ANN_LAYER_VR_CLASS_REWARD_HPP
14#define MLPACK_METHODS_ANN_LAYER_VR_CLASS_REWARD_HPP
15
16#include <mlpack/prereqs.hpp>
17
18#include "layer_types.hpp"
19
20namespace mlpack {
21namespace ann {
22
34template <
35 typename InputDataType = arma::mat,
36 typename OutputDataType = arma::mat
37>
39{
40 public:
47 VRClassReward(const double scale = 1, const bool sizeAverage = true);
48
57 template<typename InputType, typename TargetType>
58 double Forward(const InputType& input, const TargetType& target);
59
71 template<typename InputType, typename TargetType, typename OutputType>
72 void Backward(const InputType& input,
73 const TargetType& target,
74 OutputType& output);
75
77 OutputDataType& OutputParameter() const {return outputParameter; }
79 OutputDataType& OutputParameter() { return outputParameter; }
80
82 OutputDataType& Delta() const {return delta; }
84 OutputDataType& Delta() { return delta; }
85
86 /*
87 * Add a new module to the model.
88 *
89 * @param args The layer parameter.
90 */
91 template <class LayerType, class... Args>
92 void Add(Args... args) { network.push_back(new LayerType(args...)); }
93
94 /*
95 * Add a new module to the model.
96 *
97 * @param layer The Layer to be added to the model.
98 */
99 void Add(LayerTypes<> layer) { network.push_back(layer); }
100
102 std::vector<LayerTypes<> >& Model() { return network; }
103
105 bool SizeAverage() const { return sizeAverage; }
106
108 double Scale() const { return scale; }
109
113 template<typename Archive>
114 void serialize(Archive& /* ar */, const unsigned int /* version */);
115
116 private:
118 double scale;
119
121 bool sizeAverage;
122
124 double reward;
125
127 OutputDataType delta;
128
130 OutputDataType outputParameter;
131
133 std::vector<LayerTypes<> > network;
134}; // class VRClassReward
135
136} // namespace ann
137} // namespace mlpack
138
139// Include implementation.
140#include "vr_class_reward_impl.hpp"
141
142#endif
Implementation of the variance reduced classification reinforcement layer.
void Add(LayerTypes<> layer)
std::vector< LayerTypes<> > & Model()
Get the network modules.
OutputDataType & OutputParameter() const
Get the output parameter.
bool SizeAverage() const
Get the value of parameter sizeAverage.
OutputDataType & Delta() const
Get the delta.
void Backward(const InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.
VRClassReward(const double scale=1, const bool sizeAverage=true)
Create the VRClassReward object.
void serialize(Archive &, const unsigned int)
Serialize the layer.
double Forward(const InputType &input, const TargetType &target)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
double Scale() const
Get the value of scale parameter.
OutputDataType & OutputParameter()
Modify the output parameter.
OutputDataType & Delta()
Modify the delta.
boost::variant< AdaptiveMaxPooling< arma::mat, arma::mat > *, AdaptiveMeanPooling< arma::mat, arma::mat > *, Add< arma::mat, arma::mat > *, AddMerge< arma::mat, arma::mat > *, AlphaDropout< arma::mat, arma::mat > *, AtrousConvolution< NaiveConvolution< ValidConvolution >, NaiveConvolution< FullConvolution >, NaiveConvolution< ValidConvolution >, arma::mat, arma::mat > *, BaseLayer< LogisticFunction, arma::mat, arma::mat > *, BaseLayer< IdentityFunction, arma::mat, arma::mat > *, BaseLayer< TanhFunction, arma::mat, arma::mat > *, BaseLayer< SoftplusFunction, arma::mat, arma::mat > *, BaseLayer< RectifierFunction, arma::mat, arma::mat > *, BatchNorm< arma::mat, arma::mat > *, BilinearInterpolation< arma::mat, arma::mat > *, CELU< arma::mat, arma::mat > *, Concat< arma::mat, arma::mat > *, Concatenate< arma::mat, arma::mat > *, ConcatPerformance< NegativeLogLikelihood< arma::mat, arma::mat >, arma::mat, arma::mat > *, Constant< arma::mat, arma::mat > *, Convolution< NaiveConvolution< ValidConvolution >, NaiveConvolution< FullConvolution >, NaiveConvolution< ValidConvolution >, arma::mat, arma::mat > *, CReLU< arma::mat, arma::mat > *, DropConnect< arma::mat, arma::mat > *, Dropout< arma::mat, arma::mat > *, ELU< arma::mat, arma::mat > *, FastLSTM< arma::mat, arma::mat > *, FlexibleReLU< arma::mat, arma::mat > *, GRU< arma::mat, arma::mat > *, HardTanH< arma::mat, arma::mat > *, Join< arma::mat, arma::mat > *, LayerNorm< arma::mat, arma::mat > *, LeakyReLU< arma::mat, arma::mat > *, Linear< arma::mat, arma::mat, NoRegularizer > *, LinearNoBias< arma::mat, arma::mat, NoRegularizer > *, LogSoftMax< arma::mat, arma::mat > *, Lookup< arma::mat, arma::mat > *, LSTM< arma::mat, arma::mat > *, MaxPooling< arma::mat, arma::mat > *, MeanPooling< arma::mat, arma::mat > *, MiniBatchDiscrimination< arma::mat, arma::mat > *, MultiplyConstant< arma::mat, arma::mat > *, MultiplyMerge< arma::mat, arma::mat > *, NegativeLogLikelihood< arma::mat, arma::mat > *, NoisyLinear< arma::mat, arma::mat > *, Padding< arma::mat, arma::mat > *, PReLU< arma::mat, arma::mat > *, Softmax< arma::mat, arma::mat > *, SpatialDropout< arma::mat, arma::mat > *, TransposedConvolution< NaiveConvolution< ValidConvolution >, NaiveConvolution< ValidConvolution >, NaiveConvolution< ValidConvolution >, arma::mat, arma::mat > *, WeightNorm< arma::mat, arma::mat > *, MoreTypes, CustomLayers *... > LayerTypes
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.