Overview of builtin activation functions

Note that some of these functions are scaled differently from the canonical versions you may be familiar with. The intention of the scaling is to place more of the functions’ “interesting” behavior in the region \(\left[-1, 1\right] \times \left[-1, 1\right]\). Some of these are more intended for CPPNs (e.g., for HyperNEAT - the mexican_hat function is specifically intended for seeding HyperNEAT weight determination, for instance) than for “direct” problem-solving, as noted below; however, even those originally meant mainly for CPPNs can be of use elsewhere - abs and hat can both solve the xor example task in one generation, for instance (although note for the former that it is included in several others such as multiparam_relu).

The implementations of these functions can be found in the activations module.

The multiparameter functions below, and some of the others, are new; if you wish to try substituting them for previously-used activation functions, the following are suggested as possibilities among the multiparameter functions:

Old New Notes
abs multiparam_relu, multiparam_relu_softplus, or weighted_lu If the result does not need to be positive
abs fourth_square_abs If the result needs to be positive
clamped clamped_tanh_step or clamped_step  
cube multiparam_pow  
gauss hat_gauss_rectangular or multiparam_gauss Either is suitable for seeding a HyperNEAT-LEO CPPN
hat hat_gauss_rectangular  
identity multiparam_relu, multiparam_relu_softplus, multiparam_pow, or weighted_lu  
inv multiparam_log_inv If for a CPPN
log scaled_expanded_log or multiparam_log_inv If for a CPPN
relu multiparam_relu, multiparam_relu_softplus, or weighted_lu If the result does not need to be positive
relu multiparam_softplus If the result needs to be positive
sigmoid multiparam_sigmoid  
sin wave  
softplus multiparam_relu_softplus If the result does not need to be positive
softplus multiparam_softplus If the result needs to be positive
square multiparam_pow If the result does not need to be positive
square fourth_square_abs If the result needs to be positive
tanh clamped_tanh_step If the result needs to be within [-1, 1]
tanh multiparam_tanh_log1p If it does not need to be within [-1, 1]

The builtin multiparameter functions are also present to serve as examples of how to construct and configure new such functions.

Two potentially-faster approximations of the sigmoid and tanh functions have also been added, namely sigmoid_approx and tanh_approx.

General-use activation functions (single-parameter)

clamped

clamped linear function

cube

cubic function

log1p

log(x+1) function with alterations for negative numbers

relu

rectified linear function (max(x,0))

sigmoid

sigmoid function

sigmoid_approx

Potentially-faster approximation for the sigmoid function.

softplus

soft-plus function (effectively a version of relu with a curve around 0)

step

step function: -1 below 0, 0 at exactly 0, 1 above 0

tanh

hyperbolic tangent function

tanh_approx

Potentially-faster approximation for the tanh function.

General-use activation functions (multiparameter)

clamped_log1p_step

Weighted combination of (extended) clamped_step and scaled_log1p functions.
Weighted combination of (extended) clamped_step and scaled_log1p functions.

clamped_step

Clamped with varying slope, including vertical (step function)

clamped_tanh_step

Weighted combination of clamped, :ref:`tanh <tanh-label>`, and step functions.

multiparam_elu

Variable-scaling version of the exponential linear function (ELU)
Variable-scaling version of the exponential linear function (ELU)

multiparam_pow

Above a=1, pow(z, a); below 1, pow(z, pow(2,(a-1.0))

multiparam_relu

max(x, a*x), where a is an evolved parameter with a range from -1 to 1, inclusive. Acts like a weighted combination of abs, relu, and identity.

multiparam_relu_softplus

A combination of multiparam_relu and multiparam_softplus.
A combination of multiparam_relu and multiparam_softplus.

multiparam_sigmoid

A version of :ref:`clamped_tanh_step <clamped-tanh-step-label>` rescaled to match :ref:`sigmoid <sigmoid-label>` instead of :ref:`tanh <tanh-label>`.

multiparam_sigmoid_approx

A version of multiparam_tanh_approx rescaled to match :ref:`sigmoid <sigmoid-label>` instead of :ref:`tanh <tanh-label>`, and constrained to 0-1

multiparam_softplus

A version of softplus with variable curvature at 0 x.

multiparam_tanh_approx

An adjustable version of tanh_approx.
An adjustable version of tanh_approx.

multiparam_tanh_log1p

A weighted combination of :ref:`clamped_tanh_step <clamped-tanh-step-label>` and scaled_log1p.
A weighted combination of :ref:`clamped_tanh_step <clamped-tanh-step-label>` and scaled_log1p.

scaled_log1p

A version of log1p with variable scaling (with partially-counterbalancing weights inside and outside the log1p function).

weighted_lu

A weighted combination of multiparam_relu and multiparam_elu.
A weighted combination of multiparam_relu and multiparam_elu.

CPPN-intended activation functions (single-parameter)

abs

absolute value function

gauss

gaussian function

hat

hat function

identity

identity function

rectangular

rectangular impulse function

CPPN-intended activation functions (multiparameter)

bicentral

This combination of two sigmoid functions is taken from the article “Taxonomy of neural transfer functions” [taxonomy], with adjustments.

A combination of two oppositely-aligned sigmoids
A combination of two oppositely-aligned sigmoids
A combination of two oppositely-aligned sigmoids
A combination of two oppositely-aligned sigmoids
A combination of two oppositely-aligned sigmoids
A combination of two oppositely-aligned sigmoids

hat_gauss_rectangular

Weighted mean of hat, gauss, and rectangular functions.
Weighted mean of hat, multiparam_gauss, and rectangular functions

multiparam_gauss

Gauss with variations on exponent, effective SD
Gauss with variations on exponent, effective SD

rational_quadratic

Rational quadratic kernel
Rational quadratic kernel

CPPN-use activation functions (single-parameter)

exp

exponential function

expanded_log

Expanded-range log function.

inv

inverse (1/x) function

log

log function

sin

sine function

skewed_log1p

shifted log-plus function

square

square function

square_wave

Square wave with period matching sin activation function

triangle_wave

Triangle wave with period matching sin activation function

CPPN-use activation functions (multiparameter)

fourth_square_abs

A weighted combination of x**4, x**2, and abs

mexican_hat

Parameterized "mexican hat" function for HyperNEAT CPPN weight determination
Parameterized "mexican hat" function for HyperNEAT CPPN weight determination

multiparam_log_inv

Above 0.0, from scaled_expanded_log; below, weighted mean with inv of -1*x.

scaled_expanded_log

A version of expanded_log with variable scaling (with partially-counterbalancing weights both inside and outside the expanded_log function).

wave

Weighted mean of triangle_wave, sin, and square_wave activation functions.
[taxonomy]Duch, Włodzisław; Jankowski, Norbert. 2000. Taxonomy of neural transfer functions. ICJNN 2000. CiteSeerX Link.