tether.data package¶
Submodules¶
tether.data.encoding module¶
- class tether.data.encoding.SpikingDatasetWrapper(dataset, encode_fn)[source]¶
Bases:
DatasetWraps a standard dataset and applies an encoding function to the input.
- tether.data.encoding.latency_encoding(x, n_steps, tau=1.0, threshold=0.01)[source]¶
Convert continuous values to spike trains using latency encoding. Higher values fire earlier.
- Parameters:
x (torch.Tensor) – Input tensor.
n_steps (int) – Number of time steps.
tau (float) – Time constant.
threshold (float) – Threshold below which no spike is generated.
- Returns:
Spike tensor with shape (n_steps, *x.shape).
- Return type:
torch.Tensor
- tether.data.encoding.rate_encoding(x, n_steps, gain=1.0)[source]¶
Convert continuous values to spike trains using rate encoding (Bernoulli).
- Parameters:
x (torch.Tensor) – Input tensor with continuous values (usually in [0, 1]).
n_steps (int) – Number of time steps to simulate.
gain (float) – Scaling factor for firing probability.
- Returns:
Spike tensor with shape (n_steps, *x.shape).
- Return type:
torch.Tensor
Module contents¶
- class tether.data.SpikingDatasetWrapper(dataset, encode_fn)[source]¶
Bases:
DatasetWraps a standard dataset and applies an encoding function to the input.
- tether.data.latency_encoding(x, n_steps, tau=1.0, threshold=0.01)[source]¶
Convert continuous values to spike trains using latency encoding. Higher values fire earlier.
- Parameters:
x (torch.Tensor) – Input tensor.
n_steps (int) – Number of time steps.
tau (float) – Time constant.
threshold (float) – Threshold below which no spike is generated.
- Returns:
Spike tensor with shape (n_steps, *x.shape).
- Return type:
torch.Tensor
- tether.data.rate_encoding(x, n_steps, gain=1.0)[source]¶
Convert continuous values to spike trains using rate encoding (Bernoulli).
- Parameters:
x (torch.Tensor) – Input tensor with continuous values (usually in [0, 1]).
n_steps (int) – Number of time steps to simulate.
gain (float) – Scaling factor for firing probability.
- Returns:
Spike tensor with shape (n_steps, *x.shape).
- Return type:
torch.Tensor