math.py

math.py#

Smooth functions and their derivatives.

aviary.utils.math.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.d_smooth_int_tanh(x, mu=10.0)[source]

Smooth approximation of int(x) using tanh. Returns (y, dy_dx).

aviary.utils.math.d_smooth_max(x, b, mu=10.0)[source]

Derivative of function smooth_min(x)

Parameters: x (float or array-like): First value. b (float or array-like): Second value. mu (float): The smoothing factor. Higher values make it closer to the true minimum. Try between 75 and 275.

Returns: float or array-like: The smooth approximation of derivative of min(x, b).

aviary.utils.math.d_smooth_min(x, b, mu=100.0)[source]

Derivative of function smooth_min(x)

Parameters: x (float or array-like): First value. b (float or array-like): Second value. mu (float): The smoothing factor. Higher values make it closer to the true minimum. Try between 75 and 275.

Returns: float or array-like: The smooth approximation of derivative of min(x, b).

aviary.utils.math.dydx_sin_int(val)[source]

Define the derivative (dy/dx) of sin_int, at x = val.

aviary.utils.math.dydx_sin_int4(val)[source]

Define the derivative (dy/dx) of sin_int4, at x = val.

aviary.utils.math.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.sin_int(val)[source]

Define one step in approximating the ‘int’ function with a smooth, differentialbe function.

aviary.utils.math.sin_int4(val)[source]

Define a smooth, differentialbe approximation to the ‘int’ function.

aviary.utils.math.smooth_int_tanh(x, mu=10.0)[source]

Smooth approximation of int(x) using tanh.

aviary.utils.math.smooth_max(x, b, mu=10.0)[source]

Smooth approximation of the min function using the log-sum-exp trick.

Parameters: x (float or array-like): First value. b (float or array-like): Second value. mu (float): The smoothing factor. Higher values make it closer to the true maximum. Try between 75 and 275.

Returns: float or array-like: The smooth approximation of max(x, b).

aviary.utils.math.smooth_min(x, b, mu=100.0)[source]

Smooth approximation of the min function using the log-sum-exp trick.

Parameters: x (float or array-like): First value. b (float or array-like): Second value. mu (float): The smoothing factor. Higher values make it closer to the true minimum. Try between 75 and 275.

Returns: float or array-like: The smooth approximation of min(x, b).