def test_generate_train_max_weirdshapes(self): mz1 = Maze((3, 4, 2, 2)) mz1.set_spike_train_params(2) spikes = mz1.generate_spike_train((2, 3, 0, 1)) self.assertEqual(spikes.shape, (2, 3, 4, 2, 2)) mz2 = Maze(10) mz2.set_spike_train_params(200) spikes = mz2.generate_spike_train([5]) self.assertEqual(spikes.shape, (200, 10))
def test_generate_possible_moves(self): mz = Maze(size=(4, 7)) d = mz._generate_possible_moves(dims=4, symmetric=True) self.assertEqual(len(d.keys()), 8) self.assert_(np.array_equal(d[0], np.array([1,0]))) self.assert_(np.array_equal(d[1], np.array([3,0]))) self.assert_(np.array_equal(d[2], np.array([0,1]))) self.assert_(np.array_equal(d[3], np.array([0,6]))) for i in range(100): d = mz._generate_possible_moves(dims=4, symmetric=True) self.assertLess(d[4][0], 4) self.assertLess(d[4][1], 7) self.assertGreater(d[4][0], -4) self.assertGreater(d[4][1], -7) self.assert_(np.array_equal(d[5], -d[4])) d = mz._generate_possible_moves(dims=1, symmetric=True) self.assertEqual(len(d.keys()), 2) self.assert_(np.array_equal(d[0], np.array([1, 0]))) self.assert_(np.array_equal(d[1], np.array([3, 0]))) d = mz._generate_possible_moves(dims=16, symmetric=False) self.assertEqual(len(d.keys()), 16)
def test_get_random_position(self): mz = Maze(size=(5, 6, 7)) posz = [] for i in range(100): posz.append(mz.get_random_position()) posz = np.array(posz) self.assertLess(posz.max(axis=0)[0], 5) self.assertLess(posz.max(axis=0)[1], 6) self.assertLess(posz.max(axis=0)[2], 7) mz = Maze(size=12) posz = [] for i in range(100): posz.append(mz.get_random_position()) posz = np.array(posz) self.assertLess(posz.max(axis=0), 12)
def test_init(self): mz = Maze(size=5) self.assertEqual(mz.maze_dimensionality, 1) self.assertEqual(mz.current_pos.shape, (1,)) self.assertEqual(mz.current_pos[0].shape, ())
def test_generate_train_shape(self): mz = Maze((3, 4)) mz.set_spike_train_params(20) spikes = mz.generate_spike_train((1, 1)) self.assertEqual(spikes.shape, (20, 3, 4))
def test_generate_train_max_spikes(self): mz = Maze((3, 4)) mz.set_spike_train_params(20) spikes = mz.generate_spike_train((1, 1)) self.assertEqual(spikes[:, 1, 1].sum(), 20)
theta = 0.3169981156555285 eta1 = 0.0009796194970225012 eta2 = 0.015360662582262801 dims = 2 seed = 635 tf.random.set_seed(seed) rd.seed(seed) t_steps = 100 epochs = 1500 * 6 out_in_ratio = 2**3 # Initialize maze mz = Maze((4, 4)) t_mat = mz.build_transition_matrix(dims=dims, symmetric=True) mz.set_spike_train_params(t_steps, high_freq_p=1.0, low_freq_p=0.0) n_in = mz.tot_room_number n_pop = mz.tot_room_number * out_in_ratio dt = 1 logdir = "logs/" + f"{n_in}+{n_pop}/" + "last/" + "d2/" + "thresh_norm/" + f"seed{seed}/" + datetime.now( ).strftime("%m%d-%H%M") writer = tf.summary.create_file_writer(logdir) # Initialize network [two input sets of size n_in and two output populations of size n_pop] # Block identity matrix obs_m1 = (1.0) * np.kron(np.eye(n_in), np.ones([1, out_in_ratio ])) #martin put them to 1 too