You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bindsnet/encoding/__init__.py
+36-17Lines changed: 36 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@
4
4
5
5
defbernoulli(datum, time=None, **kwargs):
6
6
'''
7
-
Generates Bernoulli-distributed spike trains based on input intensity. Inputs must be non-negative. Spikes correspond to successful Bernoulli trials, with success probability equal to (normalized in [0, 1]) input value.
7
+
Generates Bernoulli-distributed spike trains based on input intensity.
8
+
Inputs must be non-negative. Spikes correspond to successful Bernoulli
9
+
trials, with success probability equal to (normalized in [0, 1]) input value.
Generates Poisson-distributed spike trains based on input intensity. Inputs must be non-negative.
77
+
Generates Poisson-distributed spike trains based
78
+
on input intensity. Inputs must be non-negative.
72
79
73
80
Inputs:
74
81
@@ -77,7 +84,8 @@ def poisson(datum, time, **kwargs):
77
84
78
85
Returns:
79
86
80
-
| (:code:`torch.Tensor`): Tensor of shape :code:`[time, n_1, ..., n_k]` of Poisson-distributed spikes.
87
+
| (:code:`torch.Tensor`): Tensor of shape :code:`[time, n_1, ..., n_k]`
88
+
of Poisson-distributed spikes.
81
89
'''
82
90
datum=np.copy(datum)
83
91
shape, size=datum.shape, datum.size
@@ -107,29 +115,36 @@ def poisson_loader(data, time, **kwargs):
107
115
108
116
Inputs:
109
117
110
-
| :code:`data` (:code:`torch.Tensor` or iterable of :code:`torch.Tensor`s): Tensor of shape :code:`[n_samples, n_1, ..., n_k]`
118
+
| :code:`data` (:code:`torch.Tensor` or iterable of :code:`torch.Tensor`s):
119
+
Tensor of shape :code:`[n_samples, n_1, ..., n_k]`
111
120
| :code:`time` (:code:`int`): Length of Poisson spike train per input variable.
112
121
113
122
Yields:
114
123
115
-
| (:code:`torch.Tensor`): Tensors of shape :code:`[time, n_1, ..., n_k]` of Poisson-distributed spikes.
124
+
| (:code:`torch.Tensor`): Tensors of shape :code:`[time, n_1, ..., n_k]`
125
+
of Poisson-distributed spikes.
116
126
'''
117
127
foriinrange(len(data)):
118
128
yieldpoisson(data[i], time) # Encode datum as Poisson spike trains.
119
129
120
130
121
131
defrank_order(datum, time, **kwargs):
122
132
'''
123
-
Encodes data via a rank order coding-like representation. One spike per neuron, temporally ordered by decreasing intensity. Inputs must be non-negative.
133
+
Encodes data via a rank order coding-like representation. One
134
+
spike per neuron, temporally ordered by decreasing intensity.
135
+
Inputs must be non-negative.
124
136
125
137
Inputs:
126
138
127
-
| :code:`data` (:code:`torch.Tensor`): Tensor of shape :code:`[n_samples, n_1, ..., n_k]`
128
-
| :code:`time` (:code:`int`): Length of Poisson spike train per input variable.
139
+
| :code:`data` (:code:`torch.Tensor`): Tensor
140
+
of shape :code:`[n_samples, n_1, ..., n_k]`
141
+
| :code:`time` (:code:`int`): Length of rank
142
+
order-encoded spike train per input variable.
129
143
130
144
Returns:
131
145
132
-
| (:code:`torch.Tensor`): Tensor of shape :code:`[time, n_1, ..., n_k]` of Poisson-distributed spikes.
146
+
| (:code:`torch.Tensor`): Tensor of shape
147
+
:code:`[time, n_1, ..., n_k]` of rank order-encoded spikes.
133
148
'''
134
149
datum=np.copy(datum)
135
150
shape, size=datum.shape, datum.size
@@ -155,16 +170,20 @@ def rank_order(datum, time, **kwargs):
155
170
156
171
defrank_order_loader(data, time, **kwargs):
157
172
'''
158
-
Lazily invokes :code:`bindsnet.encoding.rank_order` to iteratively encode a sequence of data.
0 commit comments