mlpack
c_relu_impl.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LAYER_C_RELU_IMPL_HPP
13 #define MLPACK_METHODS_ANN_LAYER_C_RELU_IMPL_HPP
14 
15 // In case it hasn't yet been included.
16 #include "c_relu.hpp"
17 
18 namespace mlpack {
19 namespace ann {
20 
21 template<typename InputDataType, typename OutputDataType>
23 {
24  // Nothing to do here.
25 }
26 
27 template<typename InputDataType, typename OutputDataType>
28 template<typename InputType, typename OutputType>
30  const InputType& input, OutputType& output)
31 {
32  output = arma::join_cols(arma::max(input, 0.0 * input), arma::max(
33  (-1 * input), 0.0 * input));
34 }
35 
36 template<typename InputDataType, typename OutputDataType>
37 template<typename DataType>
39  const DataType& input, const DataType& gy, DataType& g)
40 {
41  DataType temp;
42  temp = gy % (input >= 0.0);
43  g = temp.rows(0, (input.n_rows / 2 - 1)) - temp.rows(input.n_rows / 2,
44  (input.n_rows - 1));
45 }
46 
47 template<typename InputDataType, typename OutputDataType>
48 template<typename Archive>
50  Archive& /* ar */,
51  const uint32_t /* version */)
52 {
53  // Nothing to do here.
54 }
55 
56 } // namespace ann
57 } // namespace mlpack
58 
59 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
CReLU()
Create the CReLU object.
Definition: c_relu_impl.hpp:22
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
Definition: c_relu_impl.hpp:29
void serialize(Archive &, const uint32_t)
Serialize the layer.
Definition: c_relu_impl.hpp:49
void Backward(const DataType &input, const DataType &gy, DataType &g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
Definition: c_relu_impl.hpp:38