23 #ifndef MLPACK_METHODS_ANN_LAYER_RELU6_IMPL_HPP 24 #define MLPACK_METHODS_ANN_LAYER_RELU6_IMPL_HPP 32 template<
typename InputDataType,
typename OutputDataType>
38 template<
typename InputDataType,
typename OutputDataType>
39 template<
typename InputType,
typename OutputType>
41 const InputType& input, OutputType& output)
43 OutputType outputTemp(arma::size(input));
45 output = arma::zeros<OutputType>(arma::size(input));
46 output = arma::min(arma::max(output, input), outputTemp);
49 template<
typename InputDataType,
typename OutputDataType>
50 template<
typename DataType>
52 const DataType& input,
const DataType& gy, DataType& g)
54 DataType derivative(arma::size(gy));
56 for (
size_t i = 0; i < input.n_elem; ++i)
58 if (input(i) < 6 && input(i) > 0)
65 template<
typename InputDataType,
typename OutputDataType>
66 template<
typename Archive>
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
ReLU6()
Create the ReLU6 object.
Definition: relu6_impl.hpp:33
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: relu6_impl.hpp:51
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: relu6_impl.hpp:67
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: relu6_impl.hpp:40