Exemple #1
0
    def __init__(self):
        super().__init__()

        # initialize layers
        snn.LIF.clear_instances()  # boilerplate
        self.fc1 = nn.Linear(1, 1)
        self.lif1 = snn.Synaptic(alpha=0.5,
                                 beta=0.5,
                                 num_inputs=1,
                                 batch_size=1,
                                 init_hidden=True)
        self.lif2 = snn.Alpha(alpha=0.6,
                              beta=0.5,
                              num_inputs=1,
                              batch_size=1,
                              hidden_init=True)
def test_fire():
    synaptic = snn.Synaptic(alpha=0.5, beta=0.5)
    input_large = torch.Tensor([synaptic.threshold * 10])
    assert synaptic.fire(input_large)[0] == 1
def test_instances():
    snn.SpikingNeuron.instances = []
    snn.Synaptic(alpha=0.5, beta=0.5)
    snn.Alpha(alpha=0.5, beta=0.4)
    assert len(snn.SpikingNeuron.instances) == 2
def synaptic_hidden_reset_none_instance():
    return snn.Synaptic(alpha=0.5,
                        beta=0.5,
                        init_hidden=True,
                        reset_mechanism="none")
def synaptic_hidden_instance():
    return snn.Synaptic(alpha=0.5, beta=0.5, init_hidden=True)
def synaptic_reset_none_instance():
    return snn.Synaptic(alpha=0.5, beta=0.5, reset_mechanism="none")
def synaptic_reset_zero_instance():
    return snn.Synaptic(alpha=0.5, beta=0.5, reset_mechanism="zero")
def synaptic_instance():
    return snn.Synaptic(alpha=0.5, beta=0.5)