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

Class TestAnalyzer

test/analysis/test_analyzers.py:9–55  ·  view source on GitHub ↗

Sanity checks all plotting functions for analyzers

Source from the content-addressed store, hash-verified

7
8
9class TestAnalyzer:
10 """
11 Sanity checks all plotting functions for analyzers
12 """
13
14 def test_init(self):
15 ma = MatplotlibAnalyzer()
16 assert plt.isinteractive()
17
18 ta = TensorboardAnalyzer("./logs/init")
19
20 # check to ensure path was written
21 assert os.path.isdir("./logs/init")
22
23 # check to ensure we can write data
24 ta.writer.add_scalar("init_scalar", 100.0, 0)
25 ta.writer.close()
26
27 def test_plot_runs(self):
28 ma = MatplotlibAnalyzer()
29 ta = TensorboardAnalyzer("./logs/runs")
30
31 for analyzer in [ma, ta]:
32 obs = torch.rand(1, 28, 28)
33 analyzer.plot_obs(obs)
34
35 # 4 channels out, 1 channel in, 8x8 kernels
36 conv_weights = torch.rand(4, 1, 8, 8)
37 analyzer.plot_conv2d_weights(conv_weights)
38
39 rewards = [0, 0, 0, 0, 0]
40 analyzer.plot_reward(rewards)
41
42 # Monitors have time as last dimension
43 v = torch.rand(50, 1, 1, 28, 28)
44 voltage_dict = {"X": v}
45 threshold_dict = {"X": torch.tensor(0.75)}
46 analyzer.plot_voltages(voltage_dict, threshold_dict)
47
48 # The monitors have time as last dimension
49 spikes = torch.rand(50, 1, 1, 28, 28) > 0.5
50 spike_dict = {"X": spikes}
51 analyzer.plot_spikes(spike_dict)
52
53 analyzer.finalize_step()
54
55 ta.writer.close()
56
57
58if __name__ == "__main__":

Callers 1

test_analyzers.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected