HumbleTeacher#
- class HumbleTeacher(alpha=None, weights=None, feedback=None, input=None, **kwargs)[source]#
Bases:
objectA humble teacher learning rule (Kruschke, 1992; Love, Gureckis, and Medin, 2004) for multi-dimensional outcome learning.
- Parameters:
- alpha
float The learning rate.
- weightsarray_like
The input value. The stimulus representation in the form of a 1D array, where each element can take a value of 0 and 1.
- feedbackarray_like
The target values or feedback, sometimes referred to as teaching signals. These are the values that the algorithm should learn to predict.
- inputarray_like
The input value. The stimulus representation in the form of a 1D array, where each element can take a value of 0 and 1.
- **kwargs
dict, optional Additional keyword arguments.
- alpha
- Attributes:
- alpha
float The learning rate.
- input
ndarrayor array_like The input value. The stimulus representation in the form of a 1D array, where each element can take a value of 0 and 1.
- weights
ndarray The weights value. A 2D array of weights, where each row represents an outcome and each column represents a single stimulus.
- teacher
ndarray The target values or feedback, sometimes referred to as teaching signals. These are the values that the algorithm should learn to predict.
- shape
tuple The shape of the weight matrix.
- alpha
Notes
The humble teacher is a learning rule that is based on the idea that if output node activations are larger than the teaching signal, they should not be counted as error, but should be rewarded. It is defined as:
\[\begin{split}t_k = \begin{cases} \min(-1, a_k) & \text{if } t_k = 0 \text{ if stimulus is not followed by outcome/category-label} \\ \max(1, a_k) & \text{if } t_k = 1 \text{ if stimulus is followed by outcome/category-label} \end{cases}\end{split}\]where \(t_k\) is the teaching signal. Then the change in weights is computed according to the delta rule (Rescorla & Wagner, 1972; Rumelhart, Hinton & Williams, 1986; Gluck & Bower, 1988):
\[\Delta w_{ij} = \alpha \cdot (t_k - a_k) \cdot x_j\]where \(\Delta w_{ij}\) is the change in weight for the \(j\)-th stimulus for the \(i\)-th outcome, \(t_k\) is the teaching signal for the \(k\)-th outcome, \(a_k\) is the summed activation of all nodes connected to the \(k\)-th outcome, \(x_j\) is the j-th stimulus input, and \(\alpha\) is the learning rate.
References
Gluck, M. A., & Bower, G. H. (1988). From conditioning to category learning: An adaptive network model. Journal of Experimental Psychology: General, 117(3), 227–247.
Kruschke, J. K. (1992). ALCOVE: An exemplar-based connectionist model of category learning. Psychological Review, 99, 22–44.
Rescorla, R. A., & Wagner, A. R. (1972). A theory of Pavlovian conditioning: Variations in the effectiveness of reinforcement and nonreinforcement. In A. H. Black & W. F. Prokasy (Eds.), Classical conditioning II: Current research and theory (pp. 64-99). New York:Appleton-Century-Crofts.
Rumelhart, D. E., Hinton, G. E., & Williams, R. J. (1986). Learning representations by back-propagating errors. nature, 323(6088), 533-536.
Examples
>>> import numpy as np >>> from cpm.models.learning import HumbleTeacher >>> weights = np.array([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]]) >>> teacher = np.array([0, 1]) >>> input = np.array([1, 1, 1]) >>> humble_teacher = HumbleTeacher(alpha=0.1, weights=weights, feedback=teacher, input=input) >>> humble_teacher.compute() array([[-0.06, 0.04, 0.14], [ 0.4 , 0.5 , 0.6 ]])