54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
|
|
/// @file grotto/gadgets/activations/selu.hpp
|
||
|
|
/// @author Ryan Henry <ryan.henry@ucalgary.ca>
|
||
|
|
/// @brief
|
||
|
|
/// @copyright Copyright (c) 2019-2023 Ryan Henry and others
|
||
|
|
/// @license Released under a GNU General Public v2.0 (GPLv2) license;
|
||
|
|
/// see [LICENSE.md](@ref GPLv2) for details.
|
||
|
|
|
||
|
|
#ifndef LIBDPF_INCLUDE_GROTTO_GADGETS_ACTIVATIONS_SELU_HPP__
|
||
|
|
#define LIBDPF_INCLUDE_GROTTO_GADGETS_ACTIVATIONS_SELU_HPP__
|
||
|
|
|
||
|
|
#include <cmath>
|
||
|
|
#include <array>
|
||
|
|
#include <limits>
|
||
|
|
|
||
|
|
#include "grotto/gadget_hints.hpp"
|
||
|
|
|
||
|
|
namespace grotto
|
||
|
|
{
|
||
|
|
|
||
|
|
namespace gadgets
|
||
|
|
{
|
||
|
|
|
||
|
|
static constexpr double selu_default_alpha = 1.6732632423543772848170429916717;
|
||
|
|
static constexpr double selu_default_scale = 1.0507009873554804934193349852946;
|
||
|
|
template <double const & alpha = selu_default_alpha,
|
||
|
|
double const & scale = selu_default_scale>
|
||
|
|
struct selu
|
||
|
|
{
|
||
|
|
template <typename T>
|
||
|
|
T operator()(T x)
|
||
|
|
{
|
||
|
|
return scale*(std::max(0,x)+std::min(0,alpha*std::expm1(x)));
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
template <double const & alpha, double const & scale>
|
||
|
|
struct gadget_hints<selu<alpha, scale>>
|
||
|
|
{
|
||
|
|
static constexpr double min = std::numeric_limits<double>::min();
|
||
|
|
static constexpr double max = std::numeric_limits<double>::max();
|
||
|
|
static constexpr double poles[] = { };
|
||
|
|
static constexpr double interesting_points[] = { };
|
||
|
|
static constexpr unsigned degree = 3;
|
||
|
|
static constexpr bool has_canonical_representation = false;
|
||
|
|
static constexpr double canonical_bounds[] = { };
|
||
|
|
static constexpr std::array<double, degree+1> canonical_polys[] = { };
|
||
|
|
};
|
||
|
|
|
||
|
|
} // namespace gadgets
|
||
|
|
|
||
|
|
} // namespace grotto
|
||
|
|
|
||
|
|
#endif // LIBDPF_INCLUDE_GROTTO_GADGETS_ACTIVATIONS_SELU_HPP__
|