Beispiel #1
0
 def test_zeros_nonuniform(self):
     nonuniform = shape_stack('stack', BATCH_DIM, shape(time=1, x=3, y=3),
                              shape(x=3, y=4), shape())
     self.assertEqual(math.zeros(nonuniform).shape, nonuniform)
     self.assertEqual(math.ones(nonuniform).shape, nonuniform)
     self.assertEqual(math.random_normal(nonuniform).shape, nonuniform)
     self.assertEqual(math.random_uniform(nonuniform).shape, nonuniform)
Beispiel #2
0
 def test_zeros_nonuniform(self):
     nonuniform = shape_stack(batch('stack'),
                              batch(time=1) & spatial(x=3, y=3),
                              spatial(x=3, y=4), channel())
     self.assertEqual(math.zeros(nonuniform).shape, nonuniform)
     self.assertEqual(math.ones(nonuniform).shape, nonuniform)
     self.assertEqual(math.random_normal(nonuniform).shape, nonuniform)
     self.assertEqual(math.random_uniform(nonuniform).shape, nonuniform)
Beispiel #3
0
 def test_stack(self):
     stacked = shape_stack(batch('stack'), batch(time=1) & spatial(x=3, y=3), spatial(x=3, y=4), EMPTY_SHAPE)
     print(stacked)
     self.assertEqual(('stack', 'time', 'x', 'y'), stacked.names)
     self.assertEqual(3, stacked.get_size('stack'))
     self.assertEqual(1, stacked.get_size('time'))
     math.assert_close((3, 3, 1), stacked.get_size('x'))
     math.assert_close((3, 4, 1), stacked.get_size('y'))
     print(stacked.shape)
     self.assertEqual(('stack', 'dims'), stacked.shape.names)
     self.assertEqual(12, stacked.shape.volume)
Beispiel #4
0
 def test_stack(self):
     stacked = shape_stack('stack', BATCH_DIM, shape(time=1, x=3, y=3),
                           shape(x=3, y=4), shape())
     print(stacked)
     self.assertEqual(('stack', 'time', 'x', 'y'), stacked.names)
     self.assertEqual(3, stacked.stack)
     self.assertEqual(1, stacked.time)
     math.assert_close((3, 3, 1), stacked.x)
     math.assert_close((3, 4, 1), stacked.y)
     print(stacked.shape)
     self.assertEqual(('stack', 'dims'), stacked.shape.names)
     self.assertEqual(12, stacked.shape.volume)