**Prerequisite:** ANN | Bidirectional Associative Memory (BAM)

There are three main steps to construct the BAM model.

- Learning
- Testing
- Retrieval

Each step has been described with mathematical formulation in the article ANN | Bidirectional Associative Memory (BAM).

**Here, this learning algorithm is explained iteratively with an example.**

Assume,

Set A: Input Patterns

Set B: Corresponsing Target Patterns

** Step 1:** Here, the value of M (no of pairs of patterns) is 4.

**Assign the neurons in the input and output layer. Here, neurons in the input layer are 6 and the output layer are 3**

*Step 2:*** Step 3:** Now, compute the Weight Matrix (W):

** Step 4:** Test the BAM model learning algorithm- for the input patterns BAM will return the corresponding target patterns as output. And for each of the target patterns, BAM will return the corresponding input patterns.

- Test on input patterns (Set A) using-
- Test on target patterns (Set B) using-

Here, for each of the input patterns, the BAM model will give correct target patterns and for target patterns, the model will also give corresponding input patterns.

This signifies the bidirectional association in memory or model network.