Expand description
Activation policies, ported from tinymind (C++) cpp/activationFunctions.hpp,
cpp/lookupTable.hpp and cpp/interpolate.hpp.
C++ policy classes with static member functions become zero-sized Rust types
implementing a trait. Relu and Linear need no table and work for every
value type.
Tanh and Sigmoid are implemented for the formats that have lookup
tables (Q16_16, Q8_8): asking for Tanh on another format is a compile
error, as it is in C++ when the matching TINYMIND_USE_TANH_x_y table is not
compiled in. For f32 and f64 they compute tanh(x) and 1 / (1 + exp(-x)), as tinymind (C++)’s floating-point activations do, with the std
feature (the platform’s math library, glibc on a Linux host, which the C++
uses too: the results are bit-identical there) or the libm feature (the
libm crate, for no_std: within a few ulps of glibc, not bit-identical).
Structs§
- Linear
- The identity, for a regression output layer (C++
LinearActivationPolicy). Its gradient is unbounded; seeset_gradient_clipon the networks. - Relu
- Rectified linear unit,
max(0, x)(C++ReluActivationPolicy). - Sigmoid
- Logistic sigmoid: the 96-entry lookup table for the Q formats,
1 / (1 + exp(-x))forf32andf64(featurestdorlibm). - Tanh
- Hyperbolic tangent: the 96-entry lookup table for the Q formats,
tanhforf32andf64(featurestdorlibm).
Traits§
- Activation
- A neuron activation function and its derivative.