Пример #1
0
 def build(self):
     # check if we have the legal dimension
     if self.x == 0:
         print('ERROR! You have to assign a cluster size.')
     # 1-dimensional
     elif self.y == 0:
         for i in range(self.x):
             self.cluster.append(Neurons.LIF())
         # check whether the cluster size is correct
         if len(self.cluster) != self.x:
             print('ERROR! Size of cluster is not correct.')
         self.dimension = 1
     # 2-dimensional
     else:
         for i in range(self.x):
             self.cluster.append([])
             for j in range(self.y):
                 self.cluster[i].append(Neurons.LIF())
         # check whether the cluster size is correct
         if len(self.cluster) * len(self.cluster[0]) != self.x * self.y:
             print('ERROR! Size of cluster is not correct.')
         self.dimension = 2
Пример #2
0
# @Email   : [email protected]
# @GitHub  : https://github.com/hello-roderickwang


import Neurons
import Synapse
import Cluster
import numpy as np
import matplotlib.pyplot as plt


if __name__ == '__main__':
    x = np.linspace(-np.pi, np.pi, 201)
    sin = (np.sin(x)+1)/2

    a = Neurons.LIF()
    b = Neurons.LIF()

    weight = 2

    connection = Synapse.Synapse(a, b)
    connection.set_weight(weight)

    v_a = []
    v_b = []

    for step in range(0, len(sin)):
        a.stimulate(sin[step])
        a.go()
        v_a.append(a.out)
        connection.go()