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 
20 namespace mlpack {
21 namespace ann {
22 
34 template <
35  typename InputDataType = arma::mat,
36  typename OutputDataType = arma::mat
37 >
38 class VRClassReward
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 uint32_t /* 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
VRClassReward(const double scale=1, const bool sizeAverage=true)
Create the VRClassReward object.
Linear algebra utility functions, generally performed on matrices or vectors.
void serialize(Archive &, const uint32_t)
Serialize the layer.
The core includes that mlpack expects; standard C++ includes and Armadillo.
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
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...
OutputDataType & OutputParameter()
Modify the output parameter.
OutputDataType & Delta() const
Get the delta.
std::vector< LayerTypes<> > & Model()
Get the network modules.
bool SizeAverage() const
Get the value of parameter sizeAverage.
double Scale() const
Get the value of scale parameter.
void Backward(const InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.
void Add(LayerTypes<> layer)
OutputDataType & OutputParameter() const
Get the output parameter.
OutputDataType & Delta()
Modify the delta.