mlpack
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
bool SizeAverage() const
Get the value of parameter sizeAverage.
Definition: vr_class_reward.hpp:105
OutputDataType & Delta()
Modify the delta.
Definition: vr_class_reward.hpp:84
Implementation of the Add module class.
Definition: add.hpp:34
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.
double Scale() const
Get the value of scale parameter.
Definition: vr_class_reward.hpp:108
OutputDataType & Delta() const
Get the delta.
Definition: vr_class_reward.hpp:82
VRClassReward(const double scale=1, const bool sizeAverage=true)
Create the VRClassReward object.
Definition: vr_class_reward_impl.hpp:25
void Backward(const InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.
Definition: vr_class_reward_impl.hpp:69
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...
Definition: vr_class_reward_impl.hpp:37
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: vr_class_reward.hpp:77
std::vector< LayerTypes<> > & Model()
Get the network modules.
Definition: vr_class_reward.hpp:102
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: vr_class_reward.hpp:79
void serialize(Archive &, const uint32_t)
Serialize the layer.
Definition: vr_class_reward_impl.hpp:98