softmax#

softmax(values, beta)[source]#

The softmax policy, \(e^{\beta x_i} / \sum_j e^{\beta x_j}\), of cpm.models.decision.Softmax.

The exponentials of the scaled activations are divided by their sum. Where the largest scaled activation is beyond ±700, and the exponentials would overflow (or all underflow), the largest one is subtracted first, which gives the same function without overflow.

Parameters:
valuesnumpy.ndarray

The activations, a 1D array.

betafloat

The inverse temperature.

Returns:
numpy.ndarray

The policy. If the scaled activations contain NaN, it is NaN throughout, which Softmax then replaces.