assembly.Monitor

class assembly.Monitor(model, env_suffix='')[source]

Bases: object

Monitor the training progress.

Parameters
modelAreaInterface

A NN model, consisting of one or more areas.

Methods

assembly_similarity()

Computes the similarity of learned assemblies.

draw_model([sample])

Draw the model graph.

epoch_finished()

A sample is learned callback.

log_expected_random_overlap([n, k])

Log the expected random overlap between samples, drawn from Binomial(n, k) distribution.

log_model([space])

Log the model.

plot_associated_activations(ys_traces, …)

Plot the output layer activations for each single trace (active input area).

remove_handles()

Remove the hooks that has been used to track intermediate layers output.

reset()

trial_finished(x_samples_learned, step)

A sample is being learned callback.

update_assembly_similarity([…])

Plot the L_{0/1} similarity of the projected (learned) assemblies.

update_memory_used()

Plot the weights histograms.

update_weight_histogram()

Plot the model weights histogram.

assembly_similarity()[source]

Computes the similarity of learned assemblies.

Returns
similaritydict

A dict with pairwise assembly similarity.

draw_model(sample=None)[source]

Draw the model graph.

Parameters
sampletorch.Tensor or None, optional

Input sample. Default: None

epoch_finished()[source]

A sample is learned callback.

log_expected_random_overlap(n=1000, k=50)[source]

Log the expected random overlap between samples, drawn from Binomial(n, k) distribution.

Parameters
nint, optional

The number of neurons in a layer. Default: 1000

kint, optional

The number of active neurons in a layer. Default: 50

log_model(space='-')[source]

Log the model.

Parameters
spacestr, optional

A space substitution to correctly parse HTML later on. Default: ‘-‘

plot_associated_activations(ys_traces, ys_all_active, learned=False)[source]

Plot the output layer activations for each single trace (active input area). Overlapping neurons are shown in green.

Parameters
ys_traces(S, P, N) torch.Tensor
Stacked individual traces (output layer C activations). Axes:
  1. S - the number of (learned) samples;

  2. P - the number of incoming areas (parents);

  3. N - the number of output neurons.

ys_all_active(S, N) torch.Tensor

The output activations of layer C with all input areas active (have input).

learnedbool, optional

Have the model areas been associated (True) or not? This flag is used in the plots title only. Default: False

remove_handles()[source]

Remove the hooks that has been used to track intermediate layers output.

trial_finished(x_samples_learned, step)[source]

A sample is being learned callback.

Parameters
x_samples_learnedlist

A list of learned input vectors to recall. Each entry can be either a single vector tensor (one incoming area) or a tuple of tensors (multiple incoming areas).

stepint

The batch ID.

update_assembly_similarity(input_similarity=None, log=False)[source]

Plot the L_{0/1} similarity of the projected (learned) assemblies.

The similarity of two binary vectors \bm{x} and \bm{y} of size n that have k active neurons is computed as their dot product, divided by k:

\frac{\bm{x} \cdot \bm{y}}{k}

Parameters
input_similarityfloat or None, optional

If given, plot the input vectors similarity as well. Default: None

logbool, optional

If True, log the similarities as text. Default: False

update_memory_used()[source]

Plot the weights histograms.

update_weight_histogram()[source]

Plot the model weights histogram.