Exemple #1
0
        def derivative(V, W, t, I_ext, self):
            M_inf = (1 / 2) * (1 + bm.tanh((V - self.V1) / self.V2))
            I_Ca = self.g_Ca * M_inf * (V - self.V_Ca)
            I_K = self.g_K * W * (V - self.V_K)
            I_Leak = self.g_leak * (V - self.V_leak)
            dVdt = (-I_Ca - I_K - I_Leak + I_ext) / self.C

            tau_W = 1 / (self.phi * bm.cosh((V - self.V3) / (2 * self.V4)))
            W_inf = (1 / 2) * (1 + bm.tanh((V - self.V3) / self.V4))
            dWdt = (W_inf - W) / tau_W
            return dVdt, dWdt
Exemple #2
0
 def update(self, x):
     xh = bm.concatenate([x, self.h], axis=-1)
     if self.b is None:
         gated = xh @ self.w
     else:
         gated = xh @ self.w + self.b
     i, g, f, o = bm.split(gated, indices_or_sections=4, axis=-1)
     c = bm.sigmoid(f + 1.) * self.c + bm.sigmoid(i) * bm.tanh(g)
     h = bm.sigmoid(o) * bm.tanh(c)
     self.h.value = h
     self.c.value = c
     return self.h.value
Exemple #3
0
 def update(self, x):
     if self.bz is None:
         z = bm.sigmoid(x @ self.w_iz + self.h @ self.w_hz)
         r = bm.sigmoid(x @ self.w_ir + self.h @ self.w_hr)
         a = bm.tanh(x @ self.w_ia + (r * self.h) @ self.w_ha)
         self.h.value = (1 - z) * self.h + z * a
         return self.h.value
     else:
         z = bm.sigmoid(x @ self.w_iz + self.h @ self.w_hz + self.bz)
         r = bm.sigmoid(x @ self.w_ir + self.h @ self.w_hr + self.br)
         a = bm.tanh(x @ self.w_ia + (r * self.h) @ self.w_ha + self.ba)
         self.h.value = (1 - z) * self.h + z * a
         return self.h.value
 def dV(self, V, t, W, Iext):
   M_inf = (1 / 2) * (1 + bm.tanh((V - self.V1) / self.V2))
   I_Ca = self.g_Ca * M_inf * (V - self.V_Ca)
   I_K = self.g_K * W * (V - self.V_K)
   I_Leak = self.g_leak * (V - self.V_leak)
   dVdt = (- I_Ca - I_K - I_Leak + Iext) / self.C
   return dVdt
 def update(self, x):
     # update the hidden and output state
     dhdt = -self.h + bm.dot(x, self.w_ir)
     dhdt += bm.dot(self.r, self.w_rr)
     dhdt += bm.dot(self.o, self.w_or)
     self.h += self.dt / self.tau * dhdt
     self.r.value = bm.tanh(self.h)
     self.o.value = bm.dot(self.r, self.w_ro)
    def __init__(self,
                 num_input,
                 num_hidden,
                 num_output,
                 tau=1.0,
                 dt=0.1,
                 g=1.8,
                 alpha=1.0,
                 **kwargs):
        super(EchoStateNet, self).__init__(**kwargs)

        # parameters
        self.num_input = num_input
        self.num_hidden = num_hidden
        self.num_output = num_output
        self.tau = tau
        self.dt = dt
        self.g = g
        self.alpha = alpha

        # weights
        self.w_ir = bm.random.normal(size=(num_input,
                                           num_hidden)) / bm.sqrt(num_input)
        self.w_rr = g * bm.random.normal(
            size=(num_hidden, num_hidden)) / bm.sqrt(num_hidden)
        self.w_or = bm.random.normal(size=(num_output, num_hidden))
        w_ro = bm.random.normal(size=(num_hidden,
                                      num_output)) / bm.sqrt(num_hidden)
        self.w_ro = bm.Variable(w_ro)

        # variables
        self.h = bm.Variable(bm.random.normal(size=num_hidden) * 0.5)  # hidden
        self.r = bm.Variable(bm.tanh(self.h))  # firing rate
        self.o = bm.Variable(bm.dot(self.r, w_ro))  # output unit
        self.P = bm.Variable(bm.eye(num_hidden) *
                             self.alpha)  # inverse correlation matrix
 def dW(self, W, t, V):
   tau_W = 1 / (self.phi * bm.cosh((V - self.V3) / (2 * self.V4)))
   W_inf = (1 / 2) * (1 + bm.tanh((V - self.V3) / self.V4))
   dWdt = (W_inf - W) / tau_W
   return dWdt