forked from Shikhargupta/Spiking-Neural-Network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neuron.py
32 lines (28 loc) · 919 Bytes
/
neuron.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
############################################################ README ##############################################################
# This is neuron class which defines the dynamics of a neuron. All the parameters are initialised and methods are included to check
# for spikes and apply lateral inhibition.
###################################################################################################################################
import numpy as np
import random
from matplotlib import pyplot as plt
from parameters import param as par
class neuron:
def __init__(self):
self.t_ref = 30
self.t_rest = -1
self.P = par.Prest
def check(self):
if self.P>= self.Pth:
self.P = par.Prest
return 1
elif self.P < par.Pmin:
self.P = par.Prest
return 0
else:
return 0
def inhibit(self):
self.P = par.Pmin
def initial(self, th):
self.Pth = th
self.t_rest = -1
self.P = par.Prest