# Bidirectional associative memory

Bidirectional associative memory (BAM) is a recurrent neural network introduced by Bart Kosko in 1988 that stores hetero-associative pattern pairs, allowing recall in either direction between two fully connected layers.

Bidirectional associative memory (BAM) is a type of [recurrent neural network](https://www.wikiprompt.org/wiki/neural-network) introduced by Bart Kosko in 1988. It is a form of associative memory that stores patterns in a hetero-associative manner, meaning that given a pattern from one layer, it can retrieve a corresponding pattern from another layer, potentially of a different size. This contrasts with auto-associative memories like the [Hopfield network](https://www.wikiprompt.org/wiki/neural-network), which return patterns of the same size. BAM is bidirectional because it can respond to inputs from either the input or the output layer, using the weight matrix and its transpose for forward and backward recall.

## Topology

A BAM consists of two layers of neurons, denoted X and Y, which are fully connected to each other. Once the weights are established, presenting an input to layer X produces a pattern in layer Y, and vice versa. The connections are bidirectional: the weight matrix sent from layer X to layer Y is denoted W, and the weight matrix for signals from Y to X is the transpose W^T. Thus, the weight matrix is used in both directions, enabling symmetric recall.

## Learning

To store associations, patterns are first converted to bipolar form (1 and -1). For example, to store two associations A1:B1 and A2:B2, with A1 = (1, 0, 1, 0, 1, 0) and B1 = (1, 1, 0, 0), the bipolar forms are X1 = (1, -1, 1, -1, 1, -1) and Y1 = (1, 1, -1, -1). Similarly, A2 = (1, 1, 1, 0, 0, 0) and B2 = (1, 0, 1, 0) become X2 = (1, 1, 1, -1, -1, -1) and Y2 = (1, -1, 1, -1). The weight matrix M is computed as the sum of the outer products of each pair: M = Σ X_i^T Y_i. For the example, this yields a 6x4 matrix with entries such as 2, 0, -2, etc., reflecting the correlations between the input and output patterns.

## Recall

To retrieve an association, an input pattern is multiplied by the weight matrix. For instance, multiplying A1 (in bipolar form) by M gives (4, 2, -2, -4), which after applying a threshold (positive values become 1, negative become 0) yields (1, 1, 0, 0), which is B1. The reverse association is obtained by multiplying the output pattern by the transpose of M, allowing recall from Y to X.

## Capacity

The storage capacity of a BAM is given by min(m, n), where n is the number of units in the X layer and m is the number of units in the Y layer. The internal weight matrix has n x p independent degrees of freedom, where n is the dimension of the first vector (e.g., 6) and p is the dimension of the second vector (e.g., 4). This allows the BAM to reliably store and recall up to min(n, p) independent vector pairs; in the example, min(6, 4) = 4. Capacity can be increased beyond this at the cost of reliability, introducing incorrect bits in the output.

## Stability

A pair (A, B) defines the state of a BAM. For a pattern to be stored, its energy function value must occupy a minimum in the energy landscape. Kosko proposed the Lyapunov (energy) function E(A, B) = -A M B^T for the bidirectional case. When a paired pattern is presented, neurons change states until a bi-directionally stable state (A_f, B_f) is reached, which Kosko proved corresponds to a local minimum of the energy function. The discrete BAM is guaranteed to converge to a stable state. For the special case where A = B, the energy function reduces to E(A, A) = -A M A^T, which matches the Hopfield network's auto-associative energy function.

## See also

- [Hopfield network](https://www.wikiprompt.org/wiki/neural-network)
- [Machine learning](https://www.wikiprompt.org/wiki/machine-learning)

## External links

- [Wikipedia: Bidirectional associative memory](https://en.wikipedia.org/wiki/Bidirectional_associative_memory)

---
Source: https://www.wikiprompt.org/wiki/bidirectional-associative-memory
License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
Last updated: 2026-09-14T04:22:46.359186+00:00
