Sigmoid#
- class Sigmoid(temperature=None, activations=None, beta=0, **kwargs)[source]#
Bases:
objectA class representing a sigmoid function that takes an n by m array of activations and returns an n array of outputs, where n is the number of output and m is the number of inputs.
- Parameters:
Notes
The sigmoid function is a special case of the softmax function, where the output is of length 1. The current implementation is based on Gluck and Bower’s (1988) logistic choice function. Our current implementation is based on the following equation:
\[P(x) = \frac{1}{1 + e^{-\theta (x - \beta)}}\]where \(\theta\) is the inverse temperature parameter, \(x\) is the input array of activations, and \(\beta\) is the bias parameter. The bias parameter is not part of the original Gluck and Bower (1988) model. bias in the current implementation helps comparisons between simulations using the act2probrat logistic choice function. Set bias to 0 for operation as specified in Gluck & Bower (1988). Also note that, where there is more than one output node, the same bias value is subtracted from the output of each node. This form of decision mechanism is not present in the literature as far as we are aware, although using a negative bias value would, in multi-outcome cases, approximate a ‘background noise’ decision rule, as used in, for example, Nosofsky et al. (1994).
Examples
>>> from cpm.models.decision import Sigmoid >>> import numpy as np >>> temperature = 7 >>> activations = np.array([[0.1, 0.2]]) >>> sigmoid = Sigmoid(temperature=temperature, activations=activations) >>> sigmoid.compute() array([[0.66818777, 0.80218389]])
- compute()[source]#
Computes the Sigmoid function.
- Returns:
- output:
ndarray A 2D array of outputs computed using the sigmoid function.
- output:
- choice()[source]#
Chooses the action based on the sigmoid function.
- Returns:
- action:
int The chosen action based on the sigmoid function.
- action:
Notes
The choice is based on the probabilities of the sigmoid function, but it is not guaranteed that the policy values will sum to 1. Therefore, the policies are normalised to sum to 1 when generating a discrete choice.