-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseLayer.py
53 lines (40 loc) · 1.11 KB
/
BaseLayer.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
import os
sys.path.append('..')
import numpy as np
import queue
class BaseLayer(object):
def __init__(self, input_channel, input_shape, output_channel):
self.input_channel = input_channel ## Neuron number
self.input_shape = input_shape
self.output_channel = output_channel
self.t = 0
self.sample_i = 0
self.output_history = list()
self.len_t = 0
def next_t(self):
self.t += 1
def previous_t(self):
self.t -= 1
if self.t <= 0:
self.t = 0
def clear_t(self):
self.t = 0
def next_sample(self):
self.sample_i += 1
self.clear_t()
self.clear_historoy()
def previous_sample(self):
self.sample_i -= 1
if self.sample_i <= 0:
self.sample_i = 0
self.clear_t()
self.clear_historoy()
def set_sample(self, i):
self.sample_i = i
self.clear_t()
self.clear_historoy()
def clear_historoy(self):
self.output_history.clear()
def set_len_t(self, t):
self.len_t = t