(self)
| 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 | |
| 58 | if __name__ == "__main__": |
no test coverage detected