Inheritance diagram of lava.proc.monitor.models
class lava.proc.monitor.models.PyMonitorModel(proc_params=None)

Bases: PyLoihiProcessModel

This process model contains prototypical Ports and Vars to have one-to-one correspondes with Monitor process.


alias of Monitor


alias of LoihiProtocol

in_port_0: PyInPort = LavaPyType(cls=<class ''>, d_type=<class 'int'>, precision=None)
out_read_0: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'float'>, precision=24)

Guard function that determines if post lrn mgmt phase will get executed or not for the current timestep.

ref_port_0: PyRefPort = LavaPyType(cls=<class ''>, d_type=<class 'int'>, precision=None)
required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]

During this phase, RefPorts of Monitor process collects data from monitored Vars


During this phase, InPorts of Monitor process collects data from monitored OutPorts

var_read_0: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'float'>, precision=24)


Inheritance diagram of lava.proc.monitor.process
class lava.proc.monitor.process.Monitor(*args, **kwargs)

Bases: AbstractProcess

Monitor process to probe/monitor a given variable of a target process.

Monitor process is initialized without any Ports and Vars. The InPorts, RefPorts and Vars are created dynamically, as the Monitor process is used to probe OutPorts and Vars of other processes. For this purpose, Monitor process has the probe() method, which as arguments takes the target Var or OutPorts and number of time steps we want to monitor given process.

Note: Monitor currently only supports to record from a singe Var or Port.

  • data (dict) – Dictionary that is populated by monitoring data once get_data(..) method is called, has the following structure: data __monitored_process_name __monitored_var_or_out_port_name

  • proc_params (dict) – Process parameters that will be transferred to the corresponding ProcessModel. It is populated with the names of dynamically created port and var names of Monitor process, to be carried to its ProcessModel. It is a dictionary of the following structure: “RefPorts”: names of RefPorts created to monitor target Vars “VarsData1”: names of Vars created to store data from target Vars “InPorts”: names of InPorts created to monitor target OutPorts “VarsData2”: names of Vars created to store data from target OutPorts “n_ref_ports”: number of created RefPorts, also monitored Vars “n_in_ports”: number of created InPorts, also monitored OutPorts

  • target_names (dict) – The names of the targeted Processes and Vars/OutPorts to be monitored. This is used in get_data(..) method to access the target names corresponding to data-storing Vars of Monitor process during readout phase. This dict has the follwoing sturcture: key: name of the data-storing Vars, i.e. VarsData1 and VarsData2 value: [monitored_process_name, monitored_var_or_out_port_name]


Fetch and return the recorded data.

The recorded data is fetched, presented in a readable dict format and returned.


data – Data dictionary collected by Monitor Process.

Return type


plot(ax, target, *args, **kwargs)

Plot the recorded data into subplots.

Can handle recordings of multiple processes and multiple variables per process. Each process will create a separate column in the subplots, each variable will be plotted in a separate row.

  • ax (matplotlib.Axes) – Axes to plot the data into

  • target (Var or OutPort) – The target which should be plotted

  • *args – Passed to the matplotlib.plot function to customize the plot.

  • **kwargs – Passed to the matplotlib.plot function to customize the plot.


Run after __init__.

Creates one prototypical RefPort, InPort and two Vars. This ensures coherence and one-to-one correspondence between the Monitor Process and ProcessModel in terms og LavaPyTypes and Ports/Vars. These prototypical ports can later be updated inside the probe() method.

Note: This is separated from constructor, because once multi-variable monitoring is enabled, this method will be deprecated.

probe(target, num_steps)

Probe a Var or OutPort to record data from.

Record the target for num_step time steps, where target can be a Var or OutPort of a process.

  • target (Var or OutPort) – a Var or OutPort of some process to be monitored.

  • num_steps (int) – The number of steps the target Var/OutPort should be monitored.