WildnerveAI commited on
Commit
156324e
·
verified ·
1 Parent(s): feb6e46

Upload 2 files

Browse files
Files changed (2) hide show
  1. snntorch/__init__.py +27 -0
  2. snntorch/_neurons.py +14 -0
snntorch/__init__.py CHANGED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Stub implementation for snntorch package.
3
+ """
4
+ import logging
5
+ import torch
6
+
7
+ from ._neurons import LIF, Synaptic
8
+
9
+ logger = logging.getLogger(__name__)
10
+ logger.info("Using minimal stub implementation of snntorch")
11
+
12
+ # Spike generation functions used in communicator.py
13
+ class spikegen:
14
+ @staticmethod
15
+ def rate(tensor, num_steps=1, threshold=None):
16
+ """Generate spikes from tensor"""
17
+ if threshold is None:
18
+ threshold = 0.5
19
+
20
+ # Simple thresholding to generate spikes
21
+ spikes = (tensor > threshold).float()
22
+ return spikes
23
+
24
+ @staticmethod
25
+ def latency(tensor, num_steps=None, threshold=None, tau=1.0):
26
+ """Generate spikes with latency coding"""
27
+ return spikegen.rate(tensor, num_steps, threshold)
snntorch/_neurons.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Stub implementation of the snntorch._neurons module
3
+ """
4
+ import torch
5
+
6
+ class Synaptic(torch.nn.Module):
7
+ """Stub Synaptic neuron class"""
8
+ def __init__(self, alpha=0.1, beta=0.9):
9
+ super().__init__()
10
+ self.alpha = alpha
11
+ self.beta = beta
12
+
13
+ def forward(self, x):
14
+ return x