reservoirpy.observables.memory_capacity#

reservoirpy.observables.memory_capacity(model, k_max, as_list=False, series=None, test_size=0.2, seed=None)[source]#

Memory Capacity of a model

The Memory Capacity [1] (MC) measure is defined as:

\[MC = \sum_{k=1}^{k_{max}} MC_k\]

where:

\[MC_k = \rho^2(u(t-k), y_k(t)) = {cov^2[u(t-k), y_k(t)] \over var(u(t-k)) \cdot var(y_k(t))}\]

This measure is commonly used in reservoir computing to evaluate the ability of a network to recall the previous timesteps. By default, the timeseries \(u\) is an i.i.d. uniform signal in [-0.8, 0.8].

Parameters:
  • model (reservoirpy.Model) – A ReservoirPy model on which the memory capacity is tested. Must have only one input and output node.

  • k_max (int) – Maximum time lag between input and output. A common rule of thumb is to choose k_max = 2*reservoir.units.

  • as_list (bool, optional, defaults to False) – If True, returns an array in which out[k] \(= MC_{k+1}\)

  • series (array of shape (timesteps, 1), optional) – If specified, is used as the timeseries \(u\).

  • test_size (int or float) – Number of timesteps for the training phase. Can also be specified as a float ratio.

  • seed (int or numpy.random.Generator, optional) – Random state seed for reproducibility.

Returns:

  • float, between 0 and k_max.

  • If as_list is set to True, returns an array of shape (k_max, ).

Examples

>>> from reservoirpy.nodes import Reservoir, Ridge
>>> from reservoirpy.observables import memory_capacity
>>> model = Reservoir(100, sr=1, seed=1) >> Ridge(ridge=1e-4)
>>> mcs = memory_capacity(model, k_max=50, as_list=True, seed=1)
>>> print(f"Memory capacity of {model.name}: {np.sum(mcs):.4}")
Memory capacity of Model-0: 12.77

References