def derivative(self, u, t, Iext): r1 = bm.square(u) r2 = 1.0 + self.k * bm.sum(r1) r = r1 / r2 Irec = bm.dot(self.conn_mat, r) du = (-u + Irec + Iext) / self.tau return du
def update(self, _t, _dt): r1 = bm.square(self.u) r2 = 1.0 + self.k * bm.sum(r1) self.r.value = r1 / r2 Irec = bm.dot(self.conn_mat, self.r) self.u.value = self.u + (-self.u + Irec + self.input) / self.tau * _dt self.input[:] = 0.
def make_conn(self, x): assert bm.ndim(x) == 1 x_left = bm.reshape(x, (-1, 1)) x_right = bm.repeat(x.reshape((1, -1)), len(x), axis=0) d = self.dist(x_left - x_right) Jxx = self.J0 * bm.exp( -0.5 * bm.square(d / self.a)) / (bm.sqrt(2 * bm.pi) * self.a) return Jxx
def get_stimulus_by_pos(self, pos): assert bm.size(pos) == 2 x1, x2 = bm.meshgrid(self.x, self.x) value = bm.stack([x1.flatten(), x2.flatten()]).T d = self.dist(bm.abs(bm.asarray(pos) - value)) d = bm.linalg.norm(d, axis=1) d = d.reshape((self.length, self.length)) return self.A * bm.exp(-0.25 * bm.square(d / self.a))
def make_conn(self): x1, x2 = bm.meshgrid(self.x, self.x) value = bm.stack([x1.flatten(), x2.flatten()]).T d = self.dist(bm.abs(value[0] - value)) d = bm.linalg.norm(d, axis=1) d = d.reshape((self.length, self.length)) Jxx = self.J0 * bm.exp( -0.5 * bm.square(d / self.a)) / (bm.sqrt(2 * bm.pi) * self.a) return Jxx
def update(self, _t, _dt): r1 = bm.square(self.u) r2 = 1.0 + self.k * bm.sum(r1) self.r.value = r1 / r2 r = bm.fft.fft2(self.r) jjft = bm.fft.fft2(self.conn_mat) interaction = bm.real(bm.fft.ifft2(r * jjft)) self.u.value = self.u + (-self.u + self.input + interaction) / self.tau * _dt self.input[:] = 0.
def get_stimulus_by_pos(self, pos): return self.A * bm.exp(-0.25 * bm.square(self.dist(self.x - pos) / self.a))
def make_conn(self): x_left = bm.reshape(self.x, (-1, 1)) x_right = bm.repeat(self.x.reshape((1, -1)), len(self.x), axis=0) d = self.dist(x_left - x_right) conn = self.J0 * bm.exp(-0.5 * bm.square(d / self.a)) / (bm.sqrt(2 * bm.pi) * self.a) return conn