Tasks

This package is solely focused on specifc class tasks that can be expressed in terms of of some input-output relations and nothing else. This condition, despite seeming trivial, is by no means generic, especially when behaving animals in the wild are taken into account.

More formally, such and assumption reduces the class of tasks to time-dependent target functions \(y(t)\) that can be cast as some complex transformation of only the input \(u(t)\):

\[y(t) = \mathcal F[u(t)]\]

Importantly, for such class of problems, the internal state \(X(t)\) of the computing machine (the brain) has no influence on the target function.

Important

Due to the pure dependence of the output on the input, we deem these class of tasks as the most generic form working memory tasks. Indeed, all experimental cognitive tasks can be expressed in such form.

We focus on three instance of this class explained below.

Taylor:

Named after Taylor series (https://en.wikipedia.org/wiki/Taylor_series), the aim of this task is to compute different powers tof the input:

\[y(t) = u(t)^d\]
Nostradamus:

Named after Michel de Nostredame (https://en.wikipedia.org/wiki/Nostradamus), this tasks aims to predict the future (\(\Delta > 0\)) or recall the past (\(\Delta < 0\)) of the input:

\[y(t) = u(t+\Delta)\]
Tayloramus:

A mix of the tasks above, aiming to predict the time-shifted input raised to a particular exponent:

\[y(t) = u(t+\Delta)^d\]
class hetero.tasks.TemporalTask(name='temporal', save_type='float16', **task_params)[source]

Bases: object

An abstract class for temporal tasks. This class maintains task parameters and creates all subtasks associated with each task parameter. To this aim, it also synthesizes a potentially multi-dimensional input and processes it according to the rule imposed by the “working memory” task. It also provides a score template for registering the performance levels.

standardize(stim)[source]

Standardizes a multi-dimensional input component-wise so that the temporal mean and standard deviations are 0 and 1, respectively.

make_subtasks()[source]

creates all subtask parameters.

make_subtarget()[source]

creates a target function the task parameters.

make_stim(n_timesteps, dt_scaler=1, **stim_dict)[source]
make_target(u)[source]

Makes target array given the input timeseries.

Parameters:

u (ndarray) – Input t

Returns:

Target array

Return type:

ndarray

flatten(y, verbose=True)[source]

Flattens both target and subtasks for multi dimensional targets.

flatten_target(y, verbose=True)[source]

For Multi-dimensional targets of shape (n_subtasks, n_dim, n_timesteps), flattens the targets into an array of size (n_dim * n_subtasks, n_timesteps) where the each row first iterates over the subtask within each dimension and then switches to the next dimension.

flatten_subtasks(n_dims, verbose=True)[source]

For Multi-dimensional targets of shape (n_subtasks, n_dim, n_timesteps), target flattening must also update the subtask parameters:

(subtask_params) –> (dim, subtask_params)

The task_param repetitions are ordered such that the dim component varies after progressing over all combinations of subtasks. This is coherent with the order target orders in flatten_target.

get_score_template()[source]

Returns a pandas dataframe with the first columns indicating all subtasks

class hetero.tasks.Taylor(degrees=None, deg_min=None, deg_max=None, deg_n=None)[source]

Bases: TemporalTask

Implements the Tayor task. There are two ways to provide the exponents. Either by providing a list or by specifying the (min,max,num) of exponents. If the latter is chosen, only the integer exponent will be considered. Also note that the maximum degree is excluded.

Parameters:
  • degrees (array-like, optional) – Exponents to raise to, by default None

  • deg_min (int, optional) – Minimum exponent to raise to, by default None

  • deg_max (int, optional) – Maximum exponent to raise to, by default None

  • deg_n (int, optional) – Number of exponent between the min and max exponents, by default None

make_subtasks()[source]

creates all subtask parameters.

make_subtarget(u, degree)[source]

creates a target function the task parameters.

get_score_template()[source]

Returns a pandas dataframe with the first columns indicating all subtasks

class hetero.tasks.Nostradamus(delt_spacing='log', deltas=None, delt_min=None, delt_max=None, delt_n=None, base_stride=None)[source]

Bases: TemporalTask

Implements the Nostradamus task. There are two ways to provide the time shifts; Either by providing a list or by specifying the (min,max,num) of shifts. If the latter is chosen, only the integer exponent will be considered. Also note that the maximum degree is excluded.

Parameters:
  • deltas (array-like, optional) – An array of time shifts, by default None

  • delt_min (float, optional) – Minumum shift, by default None

  • delt_max (float, optional) – Maximum shift, by default None

  • delt_n (int, optional) – Number of shifts, will be converted to the next odd number if even, by default None

  • delt_spacing (str, optional) – The scaling between time shifts (lin for linear and log for logarithmic), by default ‘log’

  • base_stride (_type_, optional) – The number ot time samples per each unit of time, by default None

Note

The shift values must be provided in the units of the base stimulus timescale. For instance, shift values in the interval [−2,2] denote temporal shifts of the input to the past or future by up to twice the period of the main timescale of the stimulus.

make_subtasks()[source]

creates all subtask parameters.

make_subtarget(u, delta)[source]

creates a target function the task parameters.

get_score_template()[source]

Returns a pandas dataframe with the first columns indicating all subtasks

class hetero.tasks.Tayloramus(delt_spacing='log', degrees=None, deg_min=None, deg_max=None, deg_n=None, deltas=None, delt_min=None, delt_max=None, delt_n=None, base_stride=None)[source]

Bases: TemporalTask

“Implements the Tayloramus task. The arguments synopsis follows the convension of Taylor and Nostradamus tasks.

Parameters:
  • degrees (array-like, optional) – Exponents to raise to, by default None

  • deg_min (int, optional) – Minimum exponent to raise to, by default None

  • deg_max (int, optional) – Maximum exponent to raise to, by default None

  • deg_n (int, optional) – Number of exponent between the min and max exponents, by default None

  • deltas (array-like, optional) – An array of time shifts, by default None

  • delt_min (float, optional) – Minumum shift, by default None

  • delt_max (float, optional) – Maximum shift, by default None

  • delt_n (int, optional) – Number of shifts, will be converted to the next odd number if even, by default None

  • delt_spacing (str, optional) – The scaling between time shifts (lin for linear and log for logarithmic), by default ‘log’

  • base_stride (int, optional) – The number ot time samples per each unit of time, by default None

make_subtasks()[source]

creates all subtask parameters.

make_subtarget(u, delta, degree)[source]

creates a target function the task parameters.

get_score_template()[source]

Returns a pandas dataframe with the first columns indicating all subtasks

hetero.tasks.needs_synthesis(task_name)[source]

Checks if a given task requires stimulus synthesis. Those tasks in which the input and output are saved on disk, e.g,. do not need synthesis.

Has to be adapted if non-temporal tasks were added.