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

Function main

examples/dotTracing/dot_tracing.py:192–298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190
191
192def main():
193 # Build network.
194 network = Network(dt=dt)
195
196 # Input Layer
197 inpt = Input(n=dim * dim, shape=[1, 1, 1, dim, dim], traces=True)
198
199 # Hidden Layer
200 middle = LIFNodes(n=neurons, traces=True)
201
202 # Ouput Layer
203 out = LIFNodes(n=moveChoices, refrac=0, traces=True)
204
205 # Connections from input layer to hidden layer
206 inpt_middle = Connection(source=inpt, target=middle, wmin=0, wmax=1)
207
208 # Connections from hidden layer to output layer
209 middle_out = Connection(
210 source=middle,
211 target=out,
212 wmin=0, # minimum weight value
213 wmax=1, # maximum weight value
214 update_rule=MSTDPET, # learning rule
215 nu=1e-1, # learning rate
216 norm=0.5 * middle.n, # normalization
217 )
218
219 # Recurrent connection, retaining data within the hidden layer
220 recurrent = Connection(
221 source=middle,
222 target=middle,
223 wmin=0, # minimum weight value
224 wmax=1, # maximum weight value
225 update_rule=PostPre, # learning rule
226 nu=1e-1, # learning rate
227 norm=5e-3 * middle.n, # normalization
228 )
229
230 # Add all layers and connections to the network.
231 network.add_layer(inpt, name=LAYER1)
232 network.add_layer(middle, name=LAYER2)
233 network.add_layer(out, name=LAYER3)
234 network.add_connection(inpt_middle, source=LAYER1, target=LAYER2)
235 network.add_connection(middle_out, source=LAYER2, target=LAYER3)
236 network.add_connection(recurrent, source=LAYER2, target=LAYER2)
237 network.to(DEVICE)
238
239 # Add monitors
240 # network.add_monitor(Monitor(network.layers["Hidden"], ["s"], time=granularity), "Hidden")
241 # network.add_monitor(Monitor(network.layers["Output"], ["s"], time=granularity), "Output")
242 spikes = {}
243 for layer in set(network.layers):
244 spikes[layer] = Monitor(
245 network.layers[layer],
246 state_vars=["s"],
247 time=int(granularity / dt),
248 device=DEVICE,
249 )

Callers 1

dot_tracing.pyFile · 0.70

Calls 14

add_layerMethod · 0.95
add_connectionMethod · 0.95
add_monitorMethod · 0.95
resetMethod · 0.95
addFileSuffixMethod · 0.95
changeFileSuffixMethod · 0.95
NetworkClass · 0.90
InputClass · 0.90
LIFNodesClass · 0.90
ConnectionClass · 0.90
MonitorClass · 0.90
DotSimulatorClass · 0.90

Tested by

no test coverage detected