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

Method __init__

bindsnet/models/models.py:28–91  ·  view source on GitHub ↗

Constructor for class ``TwoLayerNetwork``. :param n_inpt: Number of input neurons. Matches the 1D size of the input data. :param n_neurons: Number of neurons in the ``LIFNodes`` population. :param dt: Simulation time step. :param nu: Single or pair of learni

(
        self,
        n_inpt: int,
        n_neurons: int = 100,
        dt: float = 1.0,
        wmin: float = 0.0,
        wmax: float = 1.0,
        nu: Optional[Union[float, Sequence[float]]] = (1e-4, 1e-2),
        reduction: Optional[callable] = None,
        norm: float = 78.4,
    )

Source from the content-addressed store, hash-verified

26 """
27
28 def __init__(
29 self,
30 n_inpt: int,
31 n_neurons: int = 100,
32 dt: float = 1.0,
33 wmin: float = 0.0,
34 wmax: float = 1.0,
35 nu: Optional[Union[float, Sequence[float]]] = (1e-4, 1e-2),
36 reduction: Optional[callable] = None,
37 norm: float = 78.4,
38 ) -> None:
39 # language=rst
40 """
41 Constructor for class ``TwoLayerNetwork``.
42
43 :param n_inpt: Number of input neurons. Matches the 1D size of the input data.
44 :param n_neurons: Number of neurons in the ``LIFNodes`` population.
45 :param dt: Simulation time step.
46 :param nu: Single or pair of learning rates for pre- and post-synaptic events,
47 respectively.
48 :param reduction: Method for reducing parameter updates along the minibatch
49 dimension.
50 :param wmin: Minimum allowed weight on ``Input`` to ``LIFNodes`` synapses.
51 :param wmax: Maximum allowed weight on ``Input`` to ``LIFNodes`` synapses.
52 :param norm: ``Input`` to ``LIFNodes`` layer connection weights normalization
53 constant.
54 """
55 super().__init__(dt=dt)
56
57 self.n_inpt = n_inpt
58 self.n_neurons = n_neurons
59 self.dt = dt
60
61 self.add_layer(Input(n=self.n_inpt, traces=True, tc_trace=20.0), name="X")
62 self.add_layer(
63 LIFNodes(
64 n=self.n_neurons,
65 traces=True,
66 rest=-65.0,
67 reset=-65.0,
68 thresh=-52.0,
69 refrac=5,
70 tc_decay=100.0,
71 tc_trace=20.0,
72 ),
73 name="Y",
74 )
75
76 w = 0.3 * torch.rand(self.n_inpt, self.n_neurons)
77 self.add_connection(
78 Connection(
79 source=self.layers["X"],
80 target=self.layers["Y"],
81 w=w,
82 update_rule=PostPre,
83 nu=nu,
84 reduction=reduction,
85 wmin=wmin,

Callers 4

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 5

InputClass · 0.90
LIFNodesClass · 0.90
ConnectionClass · 0.90
add_layerMethod · 0.80
add_connectionMethod · 0.80

Tested by

no test coverage detected