# Difference between revisions of "Contrastive Hebbian learning"

Contrastive Hebbian learning is an error-driven learning technique. It is a supervised learning technique, meaning that the desired outputs are known beforehand, and the task of the network is to learn to generate the desired outputs from the inputs.

As opposed to a feedforward network, a recurrent network is allowed to have connections from any neuron to any neuron in any direction. However, unlike Almeida-Pineda recurrent backpropagation, there is no backpropagation of errors; weights are updated purely via local information.

There are two phases to the model, a positive phase, also called the Hebbian or learning phase, and a negative phase, also called the anti-Hebbian or unlearning phase.

## Model

Model of a neuron. j is the index of the neuron when there is more than one neuron. The activation function for backpropagation is sigmoidal.
File:Artificial neural network.svg
A feedforward network. In the Contrastive Hebbian learning model, connections may go from any neuron to any neuron, backwards or forwards.

Given a set of k-dimensional inputs with values between 0 and 1 represented as a column vector:

$\vec{x} = [x_1, x_2, \cdots, x_k]^T$

and a nonlinear neuron with (initially random, uniformly distributed between -1 and 1) synaptic weights from the inputs:

$\vec{w} = [w_1, w_2, \cdots, w_k]^T$

then the output $y$ of the neuron is defined as follows:

\begin{align} y &= \varphi \left ( n \right ) \end{align}

where $\varphi \left ( \cdot \right )$ is a sigmoidal function such as that used in ordinary feedforward backpropagation (we will use the logistic function from that page), and $n$ is the net input of the neuron. During the positive phase, the net is written as $n^+$ with the output being $y^+$, and during the negative phase, the net is written as $n^-$ with the output being $y^-$.

Let there be $N$ neurons where some of the neurons are simple inputs to the network, some are outputs, with the weight of the connection from neuron $i$ to neuron $j$ being $w_{ij}$. Also make sure that $w_{ij} = w_{ji}$, that is, the connections and their weights are symmetric. Obviously if one of the neurons is an input, the connection going into it is useless, but nevertheless this is convenient.

The positive phase net $n^+_j$ of neuron $j$ (where $j$ is neither an input neuron nor an output neuron) is computed using a discrete time approximation to the following equation, iteratively applied to all neurons until the nets settle to some equilibrium state. Initially set $n^+_j$ to 0 for all non-input and non-output neurons.

$\frac{\mathrm{d} n^+_j}{\mathrm{d} t} = -n^+_j + \sum_{i=1}^N w_{ij} y^+_i$

where:

$y^+_i = \begin{cases} \varphi \left ( n^+_i \right ) & \text{ if } i \text{ is neither an input nor an output} \\ x_i & \text{ if } i \text{ is an input } \\ t_i & \text{ if } i \text{ is an output } \end{cases}$

where $t_i$ is a target output. Effectively, the output neurons are clamped to their target values, the inputs are applied, and the rest of the neurons are allowed to settle to equilibrium. Note that when equilibrium is reached, $\mathrm{d} n^+_j / \mathrm{d} t = 0$, and the nets are precisely equal to the weighted sum of their inputs, as expected.

Next, the negative phase nets $n^-_j$ are computed in nearly the same way, except this time start with the nets from the positive phase,[1] and the output neurons are not clamped:

$\frac{\mathrm{d} n^-_j}{\mathrm{d} t} = -n^-_j + \sum_{i=1}^N w_{ij} y^-_i$

where

$y^-_i = \begin{cases} \varphi \left ( n^-_i \right ) & \text{ if } i \text{ is not an input } \\ x_i & \text{ if } i \text{ is an input } \\ \end{cases}$

Note that if the weights between pairs of neurons are symmetric, that is, $w_{ij} = w_{ji}$, then the network is guaranteed to settle to an equilibrium state.[2] If symmetry is not held, the network will often settle.[3] Of course, if $i$ is an input, then $w_{ji}$ does not exist.

Once the positive and negative nets of the neurons are determined, the weights are updated according to the following equation:

$\Delta w_{ij} = \eta \left [ \left ( y^+_i y^+_j \right ) - \left ( y^-_i y^-_j \right ) \right ]$

where $\eta$ is some small learning rate. When the network learns the target, the negative phase exactly cancels out the positive phase, and there is no net change in weight. Also note that $\Delta w_{ij} = \Delta w_{ji}$, meaning that complementary weights go up and down in lockstep.

## Relation to cross-entropy

If, as discussed in the feedforward backpropagation derivation, the update to the weight is a gradient descent on the cross-entropy of the network, that is, $\Delta w_{ij} \propto - \partial E / \partial w_{ij}$, then the change in weight due to the positive phase, where the outputs are clamped to the target, results in a lowering of cross-entropy where the output is the target. The change in weight due to the negative phase, however, where the outputs are not the target, results in a raising of cross entropy where the output is not the target.

This has the effect of "sculpting" the cross-entropy of the network so that it ends up lower where the output is closer to the target, and higher where the output is farther away from the target.[4]

## Biological plausibility

Unlike in backpropagation modes such as feedforward backpropagation or Almeida-Pineda recurrent backpropagation, Contrastive Hebbian learning does not depend on the sending of error information backwards along connections. All the information needed to alter the weight is available locally. However, there are two phases to the model. There is some speculation that this has an analog in biological processing, where the negative phase comes first, followed by a positive phase some 300 milliseconds later.[5]

Contrastive Hebbian learning requires that weights be symmetric. There is some evidence that there are symmetric connections between cortical areas in the brain.[6]

## References

1. Template:Cite book
2. Script error: No such module "Citation/CS1".
3. Template:Cite book
4. Template:Citation/core
5. Script error: No such module "Citation/CS1".
6. Script error: No such module "Citation/CS1".