def setUp(self): self.minicolumn = Minicolumn( space_size=5, in_random_bits=1, out_random_bits=1, in_dimensions=1, out_dimensions=1, code_alignment=1, in_code_activate=0, class_point=PointNoneMock ) self.minicolumn_zeros = Minicolumn( space_size=5, in_random_bits=3, out_random_bits=3, in_dimensions=3, out_dimensions=3, code_alignment=2, seed=42, in_code_activate=0, class_point=PointZerosMock ) self.minicolumn_controversy_out = Minicolumn( space_size=5, in_random_bits=4, out_random_bits=8, in_dimensions=4, out_dimensions=8, code_alignment=4, seed=42, controversy=2, class_point=PointEmptyMock ) self.minicolumn_controversy_in = Minicolumn( space_size=200, in_random_bits=4, out_random_bits=8, in_dimensions=4, out_dimensions=8, code_alignment=2, seed=42, controversy=0.2, in_code_activate=0, class_point=PointControversyInMock ) self.minicolumn_code_alignment = Minicolumn( space_size=5, in_random_bits=4, out_random_bits=8, in_dimensions=4, out_dimensions=8, code_alignment=4, seed=42, controversy=0.1, in_code_activate=0, min_active_points=0, class_point=PointCodeAligmentMock )
def setUp(self): self.minicolumn_none = Minicolumn( space_size=100, in_random_bits=1, out_random_bits=1, in_dimensions=1, out_dimensions=1, code_alignment=1, class_point=PointNoneMock ) self.minicolumn = Minicolumn( space_size=20, in_random_bits=10, out_random_bits=10, in_dimensions=10, out_dimensions=10, seed=41, controversy=0.05, code_alignment=1, min_active_points=0, class_point=PointOddEvenMock ) self.minicolumn_front = Minicolumn( space_size=20, in_random_bits=10, out_random_bits=2, in_dimensions=10, out_dimensions=2, seed=41, controversy=0.05, code_alignment=1, class_point=PointEmptyMock ) self.minicolumn_back = Minicolumn( space_size=20, in_random_bits=2, out_random_bits=10, in_dimensions=2, out_dimensions=10, seed=41, controversy=0.05, code_alignment=1, class_point=PointEmptyMock ) self.minicolumn_assert_dim_2 = Minicolumn( space_size=20, in_random_bits=2, out_random_bits=10, in_dimensions=2, out_dimensions=10, seed=41, controversy=0.05, code_alignment=1, class_point=PointEmptyMock )
def setUp(self): self.minicolumn = Minicolumn( space_size=5, in_random_bits=1, out_random_bits=1, in_dimensions=1, out_dimensions=1, code_alignment=1, class_point=PointNoneMock )
def test_code_alignment(self): self.assertRaises(ValueError, Minicolumn, code_alignment=-5) self.assertRaises(ValueError, Minicolumn, code_alignment=None) self.assertRaises( ValueError, Minicolumn, code_alignment=3, in_dimensions=4, out_dimensions=2, in_random_bits=1, out_random_bits=1 ) self.assertRaises( ValueError, Minicolumn, code_alignment=3, in_dimensions=3, out_dimensions=2, in_random_bits=1, out_random_bits=1 ) Minicolumn( space_size=10, code_alignment=2, in_dimensions=4, out_dimensions=4, in_random_bits=1, out_random_bits=1 )
the_same_clusters) df = pd.read_csv('data/MNIST/mnist_train.csv', header=None, nrows=100) max_number = 5000 count_subimages_for_image = 10 window_size = [4, 4] space_size = 2000 minicolumn = Minicolumn(space_size=space_size, max_clusters=30000, in_dimensions=64, in_random_bits=25, out_dimensions=20, out_random_bits=15, seed=42, code_alignment=5, in_point_activate=5, out_point_activate=4, in_cluster_modify=6, out_cluster_modify=3, lr=0.3, binarization=0.1) transforms = ContextTransformer(directs=4) for i in range(space_size, 10000): np.sort(np.random.permutation(64)[:25]) np.sort(np.random.permutation(20)[:15]) means = [] delta = [] ind = 0
def setUp(self): window_size = [4, 4] width_angle = np.pi / 2 strength = 0 non_zeros_bits = 5 space_size = 500 directs = 4 self.minicolumn = Minicolumn(space_size=space_size, max_clusters=900, in_dimensions=64, in_random_bits=25, out_dimensions=20, out_random_bits=15, seed=42, code_alignment=5, in_point_activate=5, out_point_activate=4, in_cluster_modify=6, out_cluster_modify=3, lr=0.3, binarization=0.1) self.transformer = ContextTransformer(directs=directs, window_size=window_size, width_angle=width_angle, strength=strength, non_zeros_bits=non_zeros_bits) self.answer = [{ self.Answer.STATUS: MINICOLUMN.LEARN, self.Answer.OPT_OUT: np.array( [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0]), self.Answer.MEANS: 0.628, self.Answer.CONT_NUM: 314, self.Answer.OPT_IND: 7, self.Answer.EMPTY_CODE: False }, { self.Answer.STATUS: MINICOLUMN.LEARN, self.Answer.OPT_OUT: np.array( [0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), self.Answer.MEANS: 1.154, self.Answer.CONT_NUM: 577, self.Answer.OPT_IND: 20, self.Answer.EMPTY_CODE: False }, { self.Answer.STATUS: MINICOLUMN.LEARN, self.Answer.OPT_OUT: np.array( [0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), self.Answer.MEANS: 1.408, self.Answer.CONT_NUM: 704, self.Answer.OPT_IND: 14, self.Answer.EMPTY_CODE: False }, { self.Answer.STATUS: MINICOLUMN.LEARN, self.Answer.OPT_OUT: np.array( [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]), self.Answer.MEANS: 1.928, self.Answer.CONT_NUM: 964, self.Answer.OPT_IND: 29, self.Answer.EMPTY_CODE: False }, { self.Answer.STATUS: MINICOLUMN.SLEEP, self.Answer.OPT_OUT: None, self.Answer.MEANS: 1.928, self.Answer.CONT_NUM: 964, self.Answer.OPT_IND: None, self.Answer.EMPTY_CODE: False }, { self.Answer.STATUS: MINICOLUMN.SLEEP, self.Answer.OPT_OUT: None, self.Answer.MEANS: 1.928, self.Answer.CONT_NUM: 964, self.Answer.OPT_IND: None, self.Answer.EMPTY_CODE: False }]
def test_size_space(self): space_size = 100 minicolumn = Minicolumn(space_size=space_size, class_point=PointNoneMock) self.assertEqual(len(minicolumn.space), space_size)