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
Computes the similarity of learned assemblies.
draw_model
([sample])Draw the model graph.
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 the hooks that has been used to track intermediate layers output.
reset
()trial_finished
(x_samples_learned, step)A sample is being learned callback.
Plot the similarity of the projected (learned) assemblies.
Plot the weights histograms.
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
- 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:
S - the number of (learned) samples;
P - the number of incoming areas (parents);
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
- 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 similarity of the projected (learned) assemblies.
The similarity of two binary vectors and of size n that have k active neurons is computed as their dot product, divided by 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