MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / get

Method get

bindsnet/network/monitors.py:75–98  ·  view source on GitHub ↗

Return recording to user. :param var: State variable recording to return. :return: Tensor of shape ``[time, n_1, ..., n_k]``, where ``[n_1, ..., n_k]`` is the shape of the recorded state variable. Note, if time == `None`, get return the logs and empty the mo

(self, var: str)

Source from the content-addressed store, hash-verified

73 self.reset_state_variables()
74
75 def get(self, var: str) -> torch.Tensor:
76 # language=rst
77 """
78 Return recording to user.
79
80 :param var: State variable recording to return.
81 :return: Tensor of shape ``[time, n_1, ..., n_k]``, where ``[n_1, ..., n_k]`` is the shape of the recorded state
82 variable.
83 Note, if time == `None`, get return the logs and empty the monitor variable
84
85 """
86 if self.clean:
87 return_logs = torch.empty(0, device=self.device)
88 else:
89 # If the actual run length is shorter than the preallocated time,
90 # some placeholders remain and break torch.cat, so we drop them.
91 entries = [e for e in self.recording[var] if torch.is_tensor(e)]
92 if len(entries) == 0:
93 return_logs = torch.empty(0, device=self.device)
94 else:
95 return_logs = torch.cat(entries, 0)
96 if self.time is None:
97 self.recording[var] = []
98 return return_logs
99
100 def record(self) -> None:
101 # language=rst

Callers 15

TestMonitorClass · 0.45
TestNetworkMonitorClass · 0.45
test_weightsMethod · 0.45
SOM_LM-SNNs.pyFile · 0.45
reservoir.pyFile · 0.45
batch_eth_mnist.pyFile · 0.45
MCC_reservoir.pyFile · 0.45
eth_mnist.pyFile · 0.45
conv_mnist.pyFile · 0.45
runSimulatorFunction · 0.45
bernoulli_loaderFunction · 0.45

Calls

no outgoing calls

Tested by 1

test_weightsMethod · 0.36