nn.modules.timed_module.astimedmodule

class nn.modules.timed_module.astimedmodule(v1_cls: Optional[type] = None, parameters: Optional[Iterable[str]] = None, states: Optional[Iterable[str]] = None, simulation_parameters: Optional[Iterable[str]] = 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 in-depth/api-high-level.ipynb.

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__(**kwargs)
__init__ = <method-wrapper '__init__' of function object>