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

Method test_hebbian

test/network/test_learning.py:21–60  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

19 """
20
21 def test_hebbian(self):
22 # Connection test
23 network = Network(dt=1.0)
24 network.add_layer(Input(n=100, traces=True), name="input")
25 network.add_layer(LIFNodes(n=100, traces=True), name="output")
26 network.add_connection(
27 Connection(
28 source=network.layers["input"],
29 target=network.layers["output"],
30 nu=1e-2,
31 update_rule=Hebbian,
32 ),
33 source="input",
34 target="output",
35 )
36 network.run(
37 inputs={"input": torch.bernoulli(torch.rand(250, 100)).byte()}, time=250
38 )
39
40 # Conv2dConnection test
41 network = Network(dt=1.0)
42 network.add_layer(Input(shape=[1, 10, 10], traces=True), name="input")
43 network.add_layer(LIFNodes(shape=[32, 8, 8], traces=True), name="output")
44 network.add_connection(
45 Conv2dConnection(
46 source=network.layers["input"],
47 target=network.layers["output"],
48 kernel_size=3,
49 stride=1,
50 nu=1e-2,
51 update_rule=Hebbian,
52 ),
53 source="input",
54 target="output",
55 )
56 # shape is [time, batch, channels, height, width]
57 network.run(
58 inputs={"input": torch.bernoulli(torch.rand(250, 1, 1, 10, 10)).byte()},
59 time=250,
60 )
61
62 def test_post_pre(self):
63 # Connection test

Callers

nothing calls this directly

Calls 8

add_layerMethod · 0.95
add_connectionMethod · 0.95
runMethod · 0.95
NetworkClass · 0.90
InputClass · 0.90
LIFNodesClass · 0.90
ConnectionClass · 0.90
Conv2dConnectionClass · 0.90

Tested by

no test coverage detected