WildnerveAI's picture
Upload 2 files
156324e verified
raw
history blame contribute delete
812 Bytes
"""
Stub implementation for snntorch package.
"""
import logging
import torch
from ._neurons import LIF, Synaptic
logger = logging.getLogger(__name__)
logger.info("Using minimal stub implementation of snntorch")
# Spike generation functions used in communicator.py
class spikegen:
@staticmethod
def rate(tensor, num_steps=1, threshold=None):
"""Generate spikes from tensor"""
if threshold is None:
threshold = 0.5
# Simple thresholding to generate spikes
spikes = (tensor > threshold).float()
return spikes
@staticmethod
def latency(tensor, num_steps=None, threshold=None, tau=1.0):
"""Generate spikes with latency coding"""
return spikegen.rate(tensor, num_steps, threshold)