14 #ifndef MLPACK_METHODS_ANN_LAYER_FLATTEN_T_SWISH_IMPL_HPP 15 #define MLPACK_METHODS_ANN_LAYER_FLATTEN_T_SWISH_IMPL_HPP 25 template<
typename InputDataType,
typename OutputDataType>
27 const double T) : t(T)
32 template<
typename InputDataType,
typename OutputDataType>
33 template<
typename InputType,
typename OutputType>
35 const InputType& input, OutputType& output)
42 output = relu % output + t;
45 template<
typename InputDataType,
typename OutputDataType>
46 template<
typename DataType>
48 const DataType& input,
const DataType& gy, DataType& g)
50 DataType derivate, sigmoid;
52 derivate.set_size(arma::size(input));
53 for (
size_t i = 0; i < input.n_elem; ++i)
59 derivate(i) = input(i) * sigmoid(i);
60 derivate(i) = sigmoid(i) * (1.0 - derivate(i)) + derivate(i);
70 template<
typename InputDataType,
typename OutputDataType>
71 template<
typename Archive>
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: flatten_t_swish_impl.hpp:72
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
FlattenTSwish(const double T=-0.20)
Create the Flatten T Swish object using the specified parameters.
Definition: flatten_t_swish_impl.hpp:26
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: flatten_t_swish_impl.hpp:47
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: flatten_t_swish_impl.hpp:34
static double Fn(const eT x)
Computes the logistic function.
Definition: logistic_function.hpp:39
static double Fn(const double x)
Computes the rectifier function.
Definition: rectifier_function.hpp:54