Layer of nodes with user-specified spiking behavior.
| 170 | |
| 171 | |
| 172 | class Input(Nodes, AbstractInput): |
| 173 | # language=rst |
| 174 | """ |
| 175 | Layer of nodes with user-specified spiking behavior. |
| 176 | """ |
| 177 | |
| 178 | def __init__( |
| 179 | self, |
| 180 | n: Optional[int] = None, |
| 181 | shape: Optional[Iterable[int]] = None, |
| 182 | traces: bool = False, |
| 183 | traces_additive: bool = False, |
| 184 | tc_trace: Union[float, torch.Tensor] = 20.0, |
| 185 | trace_scale: Union[float, torch.Tensor] = 1.0, |
| 186 | sum_input: bool = False, |
| 187 | **kwargs, |
| 188 | ) -> None: |
| 189 | # language=rst |
| 190 | """ |
| 191 | Instantiates a layer of input neurons. |
| 192 | |
| 193 | :param n: The number of neurons in the layer. |
| 194 | :param shape: The dimensionality of the layer. |
| 195 | :param traces: Whether to record decaying spike traces. |
| 196 | :param traces_additive: Whether to record spike traces additively. |
| 197 | :param tc_trace: Time constant of spike trace decay. |
| 198 | :param trace_scale: Scaling factor for spike trace. |
| 199 | :param sum_input: Whether to sum all inputs. |
| 200 | """ |
| 201 | super().__init__( |
| 202 | n=n, |
| 203 | shape=shape, |
| 204 | traces=traces, |
| 205 | traces_additive=traces_additive, |
| 206 | tc_trace=tc_trace, |
| 207 | trace_scale=trace_scale, |
| 208 | sum_input=sum_input, |
| 209 | ) |
| 210 | |
| 211 | def forward(self, x: torch.Tensor) -> None: |
| 212 | # language=rst |
| 213 | """ |
| 214 | On each simulation step, set the spikes of the population equal to the inputs. |
| 215 | |
| 216 | :param x: Inputs to the layer. |
| 217 | """ |
| 218 | # Set spike occurrences to input values. |
| 219 | self.s = x |
| 220 | |
| 221 | super().forward(x) |
| 222 | |
| 223 | def reset_state_variables(self) -> None: |
| 224 | # language=rst |
| 225 | """ |
| 226 | Resets relevant state variables. |
| 227 | """ |
| 228 | super().reset_state_variables() |
| 229 |
no outgoing calls