Usage

The forward pass is defined in two steps:

(1)\begin{cases}
\bm{y} = \sum_l W^{input}_l \bm{x}_l +
           \alpha W^{recurrent}\bm{y}^{latent}
\\
\bm{y} = \text{kWTA}(\bm{y}, k)
\end{cases}

where \bm{x}_l are input stimuli from an incoming layer l and \bm{y}^{latent} are latent activations from a previous step; k is the number of active output neurons (winners).

Assembly areas

AreaRNNHebb(*in_features, out_features[, …])

A Hebbian-learning recurrent neural network with one or more incoming input layers and only one output layer.

AreaRNNWillshaw(*in_features, out_features)

Non-Holographic Associative Memory Area [R9c642b34848c-1]: a recurrent neural network with one or more incoming input layers and only one output layer.

AreaStack(*areas)

Vertically stacked areas.

AreaSequential()

A sequence of areas.

Activation function

KWinnersTakeAll([k_active])

K-winners-take-all activation function.

Train and simulate

Simulator(model[, epoch_size, env_suffix])

Train and simulate Computation with Assemblies.

Monitoring

Monitor(model[, env_suffix])

Monitor the training progress.

expected_random_overlap(n, k)

Computes the expected overlap of binomial sampled random vectors.

pairwise_similarity(tensors)

Computes the pairwise similarity overlap of the tensors.

Example

Associate script:

from assembly.areas import *
from assembly.samplers import sample_k_active
from assembly.simulate import Simulator

N_NEURONS, K_ACTIVE = 1000, 50

n_stim_a, n_stim_b = N_NEURONS, N_NEURONS // 2
na, nb, nc = N_NEURONS * 2, int(N_NEURONS * 1.5), N_NEURONS
area_A = AreaRNNHebb(N_NEURONS, out_features=na)
area_B = AreaRNNHebb(N_NEURONS // 2, out_features=nb)
area_C = AreaRNNHebb(na, nb, out_features=nc)
area_AB = AreaStack(area_A, area_B)
brain = AreaSequential(area_AB, area_C)
stim_a = sample_k_active(n=n_stim_a, k=K_ACTIVE)
stim_b = sample_k_active(n=n_stim_b, k=K_ACTIVE)
stim_ab = (stim_a, stim_b)
simulator = Simulator(model=brain, epoch_size=10)
simulator.simulate(x_samples=[stim_ab])

More examples are in assembly/simulate.py