vr_class_reward.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTIONS_VR_CLASS_REWARD_HPP
14 #define MLPACK_METHODS_ANN_LOSS_FUNCTIONS_VR_CLASS_REWARD_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace ann {
20 
30 template<typename MatType = arma::mat>
32 {
33  public:
40  VRClassRewardType(const double scale = 1, const bool sizeAverage = true);
41 
50  typename MatType::elem_type Forward(const MatType& input,
51  const MatType& target);
52 
64  void Backward(const MatType& input, const MatType& target, MatType& output);
65 
71  template <typename LayerType, typename... Args>
72  void Add(Args... args) { network.push_back(new LayerType(args...)); }
73 
79  void Add(Layer<MatType>* layer)
80  {
81  network.push_back(layer);
82  }
83 
85  const std::vector<Layer<MatType>*>& Network() const { return network; }
87  std::vector<Layer<MatType>*>& Network() { return network; }
88 
90  bool SizeAverage() const { return sizeAverage; }
91 
93  double Scale() const { return scale; }
94 
98  template<typename Archive>
99  void serialize(Archive& /* ar */, const uint32_t /* version */);
100 
101  private:
103  double scale;
104 
106  bool sizeAverage;
107 
109  double reward;
110 
112  std::vector<Layer<MatType>*> network;
113 }; // class VRClassRewardType
114 
115 // Default typedef for typical `arma::mat` usage.
117 
118 } // namespace ann
119 } // namespace mlpack
120 
121 // Include implementation.
122 #include "vr_class_reward_impl.hpp"
123 
124 #endif
void serialize(Archive &, const uint32_t)
Serialize the layer.
VRClassRewardType< arma::mat > VRClassReward
Linear algebra utility functions, generally performed on matrices or vectors.
MatType::elem_type Forward(const MatType &input, const MatType &target)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Scale() const
Get the value of scale parameter.
bool SizeAverage() const
Get the value of parameter sizeAverage.
VRClassRewardType(const double scale=1, const bool sizeAverage=true)
Create the VRClassRewardType object.
const std::vector< Layer< MatType > * > & Network() const
Get the network.
void Add(Args... args)
Add a new module to the model.
Implementation of the variance reduced classification reinforcement layer.
void Backward(const MatType &input, const MatType &target, MatType &output)
Ordinary feed backward pass of a neural network.
A layer is an abstract class implementing common neural networks operations, such as convolution...
Definition: layer.hpp:52
void Add(Layer< MatType > *layer)
Add a new module to the model.
std::vector< Layer< MatType > * > & Network()
Modify the network.