math_utils.py#
Smooth functions and their derivatives.
- aviary.utils.math_utils.dSigmoidXdx(x, x0, mu=1.0)[source]
Derivative of sigmoid function.
- Parameters:
x (float or array) – independent variable
x0 (float) – the center of symmetry. When x = x0, sigmoidX = 1/2.
mu (float) – steepness parameter.
- Returns:
smoothed derivative value from input parameter x.
- Return type:
float or array
- aviary.utils.math_utils.d_smooth_int_tanh(x, mu=10.0)[source]
Smooth approximation of int(x) using tanh. Returns (y, dy_dx).
- aviary.utils.math_utils.d_smooth_max(x, b, mu=10.0)[source]
Derivative of function smooth_min(x).
- Parameters:
array-like) (b (float or)
array-like)
(float) (mu)
- Returns:
float or array-like
- Return type:
The smooth approximation of derivative of min(x, b).
- aviary.utils.math_utils.d_smooth_min(x, b, mu=100.0)[source]
Derivative of function smooth_min(x).
- Parameters:
array-like) (b (float or)
array-like)
(float) (mu)
- Returns:
float or array-like
- Return type:
The smooth approximation of derivative of min(x, b).
- aviary.utils.math_utils.dydx_sin_int(val)[source]
Define the derivative (dy/dx) of sin_int, at x = val.
- aviary.utils.math_utils.dydx_sin_int4(val)[source]
Define the derivative (dy/dx) of sin_int4, at x = val.
- aviary.utils.math_utils.sigmoidX(x, x0, mu=1.0)[source]
Sigmoid used to smoothly transition between piecewise functions.
- Parameters:
x (float or array) – independent variable
x0 (float) – the center of symmetry. When x = x0, sigmoidX = 1/2.
mu (float) – steepness parameter.
- Returns:
smoothed value from input parameter x.
- Return type:
float or array
- aviary.utils.math_utils.sin_int(val)[source]
Define one step in approximating the ‘int’ function with a smooth, differentialbe function.
- aviary.utils.math_utils.sin_int4(val)[source]
Define a smooth, differentialbe approximation to the ‘int’ function.
- aviary.utils.math_utils.smooth_int_tanh(x, mu=10.0)[source]
Smooth approximation of int(x) using tanh.
- aviary.utils.math_utils.smooth_max(x, b, mu=10.0)[source]
Smooth approximation of the min function using the log-sum-exp trick.
- Parameters:
array-like) (b (float or)
array-like)
(float) (mu)
- Returns:
float or array-like
- Return type:
The smooth approximation of max(x, b).
- aviary.utils.math_utils.smooth_min(x, b, mu=100.0)[source]
Smooth approximation of the min function using the log-sum-exp trick.
- Parameters:
array-like) (b (float or)
array-like)
(float) (mu)
- Returns:
float or array-like
- Return type:
The smooth approximation of min(x, b).