Previous topic

Linear algebra operations

Next topic

Misc

This Page

Nonlinear operations

The mathutils.nonlinear module contains several useful nonlinear functions on NumPy arrays. All functions avoid memory allocation, by requiring the NumPy array in which to write the answer. All arrays should be double arrays.

This module defines the following functions:

  • sigmoid: Computes the sigmoid function.
  • dsigmoid: Computes the derivative of a sigmoid function with respect to its input.
  • tanh: Computes the tanh function.
  • dtanh: Computes the derivative of a tanh function with respect to its input.
  • reclin: Computes the rectified linear function.
  • dreclin: Computes the derivative of a rectified linear function with respect to its input.
  • softplus: Computes the softplus function.
  • softmax: Computes the softmax function.
mathutils.nonlinear.sigmoid(input, output)[source]

Computes the sigmoid function sigm(input) = 1/(1+exp(-input)) = output

mathutils.nonlinear.dsigmoid(output, doutput, dinput)[source]

Computes the derivative of a sigmoid function with respect to its input, given the output of the sigmoid and the derivative on the output.

mathutils.nonlinear.tanh(input, output)[source]

Computes the tanh function tanh(input) = (exp(2*input) - 1) / (exp(2*input) + 1) = output

mathutils.nonlinear.dtanh(output, doutput, dinput)[source]

Computes the derivative of a tanh function with respect to its input, given the output of the tanh and the derivative on the output.

mathutils.nonlinear.reclin(input, output)[source]

Computes the rectified linear function reclin(input) = 1_{input>0}*input = output

mathutils.nonlinear.dreclin(output, doutput, dinput)[source]

Computes the derivative of a rectified linear function with respect to its input, given its output and the derivative on the output.

mathutils.nonlinear.softplus(input, output)[source]

Computes the softplus function softplus(input) = log(1+exp(input))

mathutils.nonlinear.softmax(input, output)[source]

Computes the softmax function softmax(input) = exp(input)/sum(exp(input)) = output.