ThresholdSAM
- class spikeometric.models.ThresholdSAM(r: float, b: float, tau: float, dt: float, sigma: float, rho: float, theta: float, rng: torch._C.Generator)[source]
Bases:
spikeometric.models.sa_model.SAModelThe generative model used in the paper “Systematic errors in connectivity inferred from activity in strongly coupled recurrent circuits”.
Is is a threshold-based model, where the neurons spike if the synaptic activation is above a threshold. Since the model is threshold-based, it is not tunable.
It is defined by the following equations:
- \[g_i(t+1) = r \: \sum_j (W_0)_{j,i}\: s_j(t) + b_i + \mathcal{E}_i(t+1)\]
- \[\begin{split}X_i(t+1) = \begin{cases} 1 & \text{if } g_i(t+1) > \theta \\ 0 & \text{otherwise} \end{cases}\end{split}\]
where \(r\) is the scaling of the recurrent connections, \(b_i\) is the strength of a background input and \(\mathcal{E}_i(t+1)\) is an external stimulus. The response to the input is then compared to a threshold \(\theta\) and the neurons spike if the activation is above the threshold.
Between each time step, the synaptic activation is decayed by a factor of \((1-\Delta t/\tau)\) if the neuron did not spike and increased by \(\Delta t\) if it did.
- Parameters
r (float) – The scaling of the recurrent connections. (tunable)
b (float) – The strength of the background input. (tunable)
tau (float) – The time constant of the neurons.
dt (float) – The time step of the simulation.
sigma (float) – The standard deviation of the noise.
rho (float) – The sparsity of the noise.
theta (float) – The threshold of the neurons (the neurons will spike if the activation is above the threshold).
rng (torch.Generator) – The random number generator.
- input(edge_index: torch.Tensor, W: torch.Tensor, state: torch.Tensor, t=- 1) torch.Tensor[source]
Calculates the input to each neuron as:
\[g_i(t+1) = r \: \sum_j (W_0)_{j,i}\: s_j(t) + b_i + \mathcal{E}_i(t+1)\]- Parameters
edge_index (torch.Tensor [2, n_edges]) – The connectivity of the network.
W (torch.Tensor [n_edges, 1]) – The edge weights of the connectivity filter.
state (torch.Tensor [n_neurons, 1]) – The activation of the neurons at time t.
t (int) – The current time step.
- Returns
input – The input to each neuron at time t.
- Return type
torch.Tensor [n_neurons]
- background_input(n_neurons: int)[source]
Generate the background input. This is a uniform excitatory input given by the parameter \(b\) plus a scaled Gaussian noise with standard deviation \(\sigma\) and some sparsity.
- Parameters
t (int) – The current time step.
n_neurons (int) – The number of neurons in the network.
- Returns
background_input
- Return type
torch.Tensor [n_edges]
- emit_spikes(input: torch.Tensor) torch.Tensor[source]
Emit spikes from the network. The neuron will spike if the input it receives is above the threshold.
\[\begin{split}X_i(t+1) = \begin{cases} 1 & \text{if } g_i(t+1) > \theta \\ 0 & \text{otherwise} \end{cases}\end{split}\]- Parameters
activation (torch.Tensor [n_neurons]) – The activation of the neurons at the current time step.
- Returns
spikes – The spikes of the network at the current time step.
- Return type
torch.Tensor [n_neurons]
- update_activation(spikes: torch.Tensor, activation: torch.Tensor) torch.Tensor[source]
Update the activation of the neurons according to the formula:
\[s_i(t+1) = s_i(t)(1 - \frac{\Delta t}{\tau}) + X_i(t)\Delta t\]where \(s_i(t)\) is the activation of neuron \(i\) at time \(t\), \(X_i(t)\) indicates whether the neuron spiked at time \(t\) or not, and \(\tau\) is the time constant of the neurons.
- Parameters
spikes (torch.Tensor [n_neurons, 1]) – The spikes of the network at the current time step.
activation (torch.Tensor [n_neurons, 1]) – The activation of the neurons at the previous time step.
- Returns
activation – The activation of the neurons at the current time step.
- Return type
torch.Tensor [n_neurons, 1]