brainmass.datasets.delayed_match_task

brainmass.datasets.delayed_match_task#

brainmass.datasets.delayed_match_task(n_samples=128, *, seq_len=10, n_symbols=4, seed=0)[source]#

Generate a synthetic delayed-match-to-sample task.

Each trial presents a cue symbol, a delay, and a probe symbol, all one-hot encoded over n_symbols along the last axis. The binary target is 1 if the probe matches the cue and 0 otherwise. The data is fully synthetic (no bundled binary, no MNIST) and deterministic given seed.

Parameters:
  • n_samples (int) – Number of trials. Default 128.

  • seq_len (int) – Length of each input sequence (must be at least 2). The cue is at t=0 and the probe at t=seq_len-1; the steps in between are the (empty) delay. Default 10.

  • n_symbols (int) – The one-hot symbol alphabet size (last-axis depth). Default 4.

  • seed (int) – Seed for the deterministic generator. Default 0.

Return type:

Tuple[ndarray, ndarray]

Returns:

  • inputs (numpy.ndarray) – (n_samples, seq_len, n_symbols) float one-hot input sequences.

  • targets (numpy.ndarray) – (n_samples,) int match labels in {0, 1}.

See also

load_dataset

load_dataset('delayed_match_task') returns the default task.

Examples

>>> from brainmass import datasets
>>> inputs, targets = datasets.delayed_match_task(n_samples=8, seq_len=6)
>>> inputs.shape
(8, 6, 4)
>>> sorted(set(targets.tolist())) == [0, 1] or set(targets.tolist()) <= {0, 1}
True