示例#1
0
    def __init__(
        self,
        seq_length: int,
        parameters: lif.LIFParameters = lif.LIFParameters(),
        dt: float = 0.001,
    ):
        """
        Encodes input currents as fixed (constant) voltage currents, and simulates the spikes that 
        occur during a number of timesteps/iterations (seq_length).

        Example:
            >>> data = torch.tensor([2, 4, 8, 16])
            >>> seq_length = 2 # Simulate two iterations
            >>> constant_current_lif_encode(data, seq_length)
            (tensor([[0.2000, 0.4000, 0.8000, 0.0000],   # State in terms of membrane voltage
                    [0.3800, 0.7600, 0.0000, 0.0000]]), 
            tensor([[0., 0., 0., 1.],                   # Spikes for each iteration
                    [0., 0., 1., 1.]]))

        Parameters:
            seq_length (int): The number of iterations to simulate
            parameters (LIFParameters): Initial neuron parameters. Defaults to zero.
            dt (float): Time delta between simulation steps
        """
        super(ConstantCurrentLIFEncoder, self).__init__()
        self.seq_length = seq_length
        self.parameters = parameters
        self.dt = dt
示例#2
0
 def __init__(self, seq_length, parameters=lif.LIFParameters(), dt=0.001):
     super(SpikeLatencyLIFEncoder, self).__init__()
     self.seq_length = seq_length
     self.parameters = parameters
     self.dt = dt