mlpack  master
vr_class_reward.hpp
Go to the documentation of this file.
1 
8 #ifndef MLPACK_METHODS_ANN_LAYER_VR_CLASS_REWARD_HPP
9 #define MLPACK_METHODS_ANN_LAYER_VR_CLASS_REWARD_HPP
10 
11 #include <mlpack/prereqs.hpp>
12 
13 #include "layer_types.hpp"
14 
15 namespace mlpack {
16 namespace ann {
17 
29 template <
30  typename InputDataType = arma::mat,
31  typename OutputDataType = arma::mat
32 >
33 class VRClassReward
34 {
35  public:
42  VRClassReward(const double scale = 1, const bool sizeAverage = true);
43 
52  template<typename eT>
53  double Forward(const arma::Mat<eT>&& input, const arma::Mat<eT>&& target);
54 
66  template<typename eT>
67  void Backward(const arma::Mat<eT>&& input,
68  const arma::Mat<eT>&& target,
69  arma::Mat<eT>&& output);
70 
72  InputDataType& InputParameter() const {return inputParameter; }
74  InputDataType& InputParameter() { return inputParameter; }
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 
87  bool Deterministic() const { return deterministic; }
89  bool& Deterministic() { return deterministic; }
90 
91  /*
92  * Add a new module to the model.
93  *
94  * @param args The layer parameter.
95  */
96  template <class LayerType, class... Args>
97  void Add(Args... args) { network.push_back(new LayerType(args...)); }
98 
99  /*
100  * Add a new module to the model.
101  *
102  * @param layer The Layer to be added to the model.
103  */
104  void Add(LayerTypes layer) { network.push_back(layer); }
105 
109  template<typename Archive>
110  void Serialize(Archive& /* ar */, const unsigned int /* version */);
111 
112  private:
114  const double scale;
115 
117  const bool sizeAverage;
118 
120  double reward;
121 
123  OutputDataType delta;
124 
126  InputDataType inputParameter;
127 
129  OutputDataType outputParameter;
130 
133 
135  std::vector<LayerTypes> network;
136 }; // class VRClassReward
137 
138 } // namespace ann
139 } // namespace mlpack
140 
141 // Include implementation.
142 #include "vr_class_reward_impl.hpp"
143 
144 #endif
InputDataType & InputParameter() const
Get the input parameter.
OutputDataType & Delta()
Modify the delta.
OutputDataType delta
Locally-stored delta object.
InputDataType inputParameter
Locally-stored input parameter object.
bool & Deterministic()
Modify the value of the deterministic parameter.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
OutputDataType outputParameter
Locally-stored output parameter object.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & Delta() const
Get the delta.
OutputDataType & OutputParameter() const
Get the output parameter.
VRClassReward(const double scale=1, const bool sizeAverage=true)
Create the VRClassReward object.
boost::variant< Add< arma::mat, arma::mat > *, AddMerge< arma::mat, arma::mat > *, BaseLayer< LogisticFunction, arma::mat, arma::mat > *, BaseLayer< IdentityFunction, arma::mat, arma::mat > *, BaseLayer< TanhFunction, arma::mat, arma::mat > *, BaseLayer< RectifierFunction, arma::mat, arma::mat > *, Concat< 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 > *, DropConnect< arma::mat, arma::mat > *, Dropout< arma::mat, arma::mat > *, Glimpse< arma::mat, arma::mat > *, HardTanH< arma::mat, arma::mat > *, Join< arma::mat, arma::mat > *, LeakyReLU< arma::mat, arma::mat > *, Linear< arma::mat, arma::mat > *, LinearNoBias< arma::mat, arma::mat > *, 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 > *, MeanSquaredError< arma::mat, arma::mat > *, MultiplyConstant< arma::mat, arma::mat > *, NegativeLogLikelihood< arma::mat, arma::mat > *, PReLU< arma::mat, arma::mat > *, Recurrent< arma::mat, arma::mat > *, RecurrentAttention< arma::mat, arma::mat > *, ReinforceNormal< arma::mat, arma::mat > *, Select< arma::mat, arma::mat > *, Sequential< arma::mat, arma::mat > *, VRClassReward< arma::mat, arma::mat > * > LayerTypes
bool deterministic
If true dropout and scaling is disabled, see notes above.
void Add(LayerTypes layer)
const bool sizeAverage
If true take the average over all batches.
OutputDataType & OutputParameter()
Modify the output parameter.
std::vector< LayerTypes > network
Locally-stored network modules.
InputDataType & InputParameter()
Modify the input parameter.
bool Deterministic() const
Get the value of the deterministic parameter.
const double scale
Locally-stored value to scale the reward.
void Serialize(Archive &, const unsigned int)
Serialize the layer.
double Forward(const arma::Mat< eT > &&input, const arma::Mat< eT > &&target)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
void Backward(const arma::Mat< eT > &&input, const arma::Mat< eT > &&target, arma::Mat< eT > &&output)
Ordinary feed backward pass of a neural network.
double reward
Locally stored reward parameter.