nn.modules.timed_module.astimedmodule

class nn.modules.timed_module.astimedmodule(v1_cls: type | None = None, parameters: Iterable[str] | None = None, states: Iterable[str] | None = None, simulation_parameters: Iterable[str] | None = None)[source]

Bases:

Convert a Rockpool v1 class to a v2 class

This decorator transparently converts a Rockpool v1 Layer subclass to a Rockpool v2 high-level API TimedModule subclass.

You can specify the parameter, state and simulation parameter attributes of the v1 layer to expose via the v2 API.

Evolution should just workβ„’, and ideally you won’t need to modify anything in the v1 code to use the class within the v2 API. Depending on the complexity of the v1 layer, this may or may not be the case.

Examples

Specify a simple v1 layer, and convert it to a v2 Module:

from rockpool.nn.layers import Layer
from rockpool.nn.modules.timed_module import astimedmodule

@astimedmodule(
    parameters = ['tau_mem', 'tau_syn', 'bias'],
    states = ['v_mem', 'i_syn'],
    simulation_parameters = ['noise_std']
)
class my_v1_layer(Layer):
    def __init__(...):
        ...

    def evolve(...):
        ...
See Also

For more information, see ⏱ High-level TimedModule API.

Parameters:
  • v1_cls (type) – A v1 Layer subclass to wrap

  • parameters (Optional[Iterable[str]]) – An iterable set of strings, specifying the names of attributes provided by v1_cls that should be automatically registered as Rockpool Parameter s.

  • states (Optional[Iterable[str]]) – An iterable set of strings, specifying the names of attributes provided by v1_cls that should be automatically registered as Rockpool State s.

  • simulation_parameters (Optional[Iterable[str]]) – An iterable set of strings, specifying the names of attributes provided by v1_cls that should be automatically registered as Rockpool SimulationParameter s.

Returns:

A wrapped class instantiator the will create a v2 high-level API object

Return type:

LayerToTimedModule

__init__ = <method-wrapper '__init__' of function object>