Skip to content

Commit 130c0e9

Browse files
committed
dye: get things to kind of work with naive dye model
1 parent 4bc44de commit 130c0e9

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

lib/pim/models/new/stone/dye.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def update_weights(self, inputs: Output, dt: float):
2222
pass
2323

2424
def output(self, network: Network) -> Output:
25-
return network.output("CPU4") * self.weights
25+
return network.output("CPU4") * self.weights * 300000
26+
#return np.log10(network.output("CPU4") * self.weights) + 6 #* 30000
2627

2728

2829
class SimpleDyeLayer(DyeLayer):
@@ -37,14 +38,14 @@ def update_weights(self, inputs: Output, dt: float):
3738
self.weights += -self.backreaction_rate*dt + self.gain*inputs*dt
3839

3940
class AdvancedDyeLayer(DyeLayer):
40-
def __init__(self, epsilon, length, T_half, phi, c_tot):
41+
def __init__(self, epsilon, length, T_half, phi, beta, c_tot):
4142
self.epsilon = epsilon
4243
self.length = length
4344
self.k = np.log(2) / T_half
4445
self.phi = phi
4546
self.c_tot = c_tot
4647

47-
self.last_c = np.zeros(16)
48+
self.last_c = np.ones(16) * phi * beta / self.k
4849

4950
super().__init__()
5051

@@ -54,7 +55,7 @@ def dcdt(t, c):
5455
return -self.k * c + self.phi * inputs
5556

5657

57-
solution = solve_ivp(dcdt, y0 = self.last_c, t_span=(0, dt))
58+
solution = solve_ivp(dcdt, y0 = self.last_c, t_span=(0, dt*0.01))
5859
c = solution.y[:,-1]
5960
# print(c)
6061
self.last_c = c
@@ -98,6 +99,7 @@ def build_network(self) -> Network:
9899
epsilon = self.epsilon,
99100
length = self.length,
100101
T_half = self.T_half,
102+
beta = self.beta,
101103
phi = self.phi,
102104
c_tot = self.c_tot
103105
),
@@ -133,7 +135,7 @@ def build_cpu4_layer(self) -> Layer:
133135
"TB1", "TN1", "TN2",
134136
self.W_TN_CPU4,
135137
self.W_TB1_CPU4,
136-
self.cpu4_mem_gain,
138+
self.cpu4_mem_gain * 10,
137139
self.cpu4_slope,
138140
self.cpu4_bias,
139141
self.noise,

lib/pim/models/new/stone/rate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def output(self, network: Network) -> Output:
5959

6060
mem_update = np.dot(self.W_TN, tn2)
6161
mem_update -= np.dot(self.W_TB1, tb1)
62-
return noisy_sigmoid(mem_update, self.slope, self.bias, self.noise) + self.background_activity
62+
return noisy_sigmoid(mem_update, self.slope, self.bias, self.noise) * self.gain + self.background_activity
6363

6464
class CPU4Layer(Layer):
6565
def __init__(self, TB1, TN1, TN2, W_TN, W_TB1, gain, slope, bias, noise):

setups/dye-short.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"experiments": {
3+
"stone": {
4+
"model": "stone",
5+
"T_outbound": 1500,
6+
"T_inbound": 1500,
7+
"noise": 0.1,
8+
"cx": "dye",
9+
"record": ["CPU4", "memory"],
10+
"phi": 0.015,
11+
"beta": 1.0,
12+
"T_half": 0.29411764705882354,
13+
"epsilon": 2e5,
14+
"length": 50e-4,
15+
"c_tot": 0.3
16+
}
17+
}
18+
}

setups/dye.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"experiments": {
3+
"stone": {
4+
"model": "stone",
5+
"T_outbound": 1500,
6+
"T_inbound": 1500,
7+
"noise": 0.1,
8+
"cx": "dye",
9+
"record": ["CPU4", "memory"],
10+
"phi": 0.0015,
11+
"beta": 1.0,
12+
"T_half": 135.91121187449906,
13+
"epsilon": 2e5,
14+
"length": 50e-4,
15+
"c_tot": 0.3
16+
}
17+
}
18+
}

setups/stone-as-is.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"stone": {
44
"model": "stone",
55
"T_outbound": 1500,
6-
"T_inbound": 1000,
6+
"T_inbound": 1500,
77
"noise": 0.1,
8-
"cx": "pontine"
8+
"cx": "pontine",
9+
"record": ["CPU4-no-mem"]
910
}
1011
}
1112
}

0 commit comments

Comments
 (0)