(self)
| 60 | ) |
| 61 | |
| 62 | def test_post_pre(self): |
| 63 | # Connection test |
| 64 | network = Network(dt=1.0) |
| 65 | network.add_layer(Input(n=100, traces=True), name="input") |
| 66 | network.add_layer(LIFNodes(n=100, traces=True), name="output") |
| 67 | network.add_connection( |
| 68 | Connection( |
| 69 | source=network.layers["input"], |
| 70 | target=network.layers["output"], |
| 71 | nu=1e-2, |
| 72 | update_rule=PostPre, |
| 73 | ), |
| 74 | source="input", |
| 75 | target="output", |
| 76 | ) |
| 77 | network.run( |
| 78 | inputs={"input": torch.bernoulli(torch.rand(250, 100)).byte()}, time=250 |
| 79 | ) |
| 80 | |
| 81 | network2 = Network(dt=1.0) |
| 82 | network2.add_layer(Input(n=100, traces=True), name="input") |
| 83 | network2.add_layer(CSRMNodes(n=100, traces=True), name="output") |
| 84 | network2.add_connection( |
| 85 | Connection( |
| 86 | source=network2.layers["input"], |
| 87 | target=network2.layers["output"], |
| 88 | nu=1e-2, |
| 89 | update_rule=PostPre, |
| 90 | ), |
| 91 | source="input", |
| 92 | target="output", |
| 93 | ) |
| 94 | network2.run( |
| 95 | inputs={"input": torch.bernoulli(torch.rand(250, 100)).byte()}, time=250 |
| 96 | ) |
| 97 | |
| 98 | # Conv2dConnection test |
| 99 | network = Network(dt=1.0) |
| 100 | network.add_layer(Input(shape=[1, 10, 10], traces=True), name="input") |
| 101 | network.add_layer(LIFNodes(shape=[32, 8, 8], traces=True), name="output") |
| 102 | network.add_connection( |
| 103 | Conv2dConnection( |
| 104 | source=network.layers["input"], |
| 105 | target=network.layers["output"], |
| 106 | kernel_size=3, |
| 107 | stride=1, |
| 108 | nu=1e-2, |
| 109 | update_rule=PostPre, |
| 110 | ), |
| 111 | source="input", |
| 112 | target="output", |
| 113 | ) |
| 114 | network.run( |
| 115 | inputs={"input": torch.bernoulli(torch.rand(250, 1, 1, 10, 10)).byte()}, |
| 116 | time=250, |
| 117 | ) |
| 118 | |
| 119 | def test_weight_dependent_post_pre(self): |
nothing calls this directly
no test coverage detected