-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractNetwork.py
45 lines (34 loc) · 1.52 KB
/
AbstractNetwork.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
import sys
import numpy as np
from LinearTrack import LinearTrack
from generic.smart_sim import Config, SmartSim
class AbstractNetwork(SmartSim):
dependencies = [LinearTrack]
def __init__(self, num_units, tau, log_act=False, log_theta=False, log_pos_input=False, log_after=0,
config=Config(), d={}):
SmartSim.__init__(self, config, d)
if 'LinearTrack' in d:
self.track: LinearTrack = d['LinearTrack']
else:
sys.exit("A LinearTrack instance should be provided in d")
self.num_units = num_units
self.tau = tau
self.dt_over_tau = self.track.dt / tau
self.first_logged_step = int(log_after / self.track.dt)
self.logged_steps = len(self.track.x_log) - self.first_logged_step
self.log_act = log_act
if log_act:
self.act_log = np.empty((self.logged_steps, num_units))
self.act_out_log = np.empty((self.logged_steps, num_units))
self.theta_cycle_steps = 1 / (8 * self.track.dt)
self.theta_phase_inc = 2 * np.pi / self.theta_cycle_steps
self.log_theta = log_theta
if log_theta:
self.theta_log = np.empty(self.logged_steps)
self.theta_phase_log = np.empty(self.logged_steps)
self.theta_phase_log[-1] = 0
self.theta_cycle_starts = []
self.log_pos_input = log_pos_input
if log_pos_input:
self.pos_input_log = np.empty((self.logged_steps, num_units))
self.induction_speeds = None # for NetworkIndep