Exemplo n.º 1
0
 def testStructureFromTensor(self):
     with self.test_session():
         inputs = tf.constant(_rand(1, 18, 19, 5))
         spec = "net = Cr(64, [5, 5])"
         outputs = specs.create_net(spec, inputs)
         tf.global_variables_initializer().run()
         result = outputs.eval()
         self.assertEqual(tuple(result.shape), (1, 18, 19, 64))
         self.assertEqual(summaries.tf_spec_structure(spec, inputs),
                          "_ var conv var biasadd relu")
Exemplo n.º 2
0
 def testMpPower(self):
     with self.test_session():
         inputs = tf.constant(_rand(1, 64, 64, 5))
         spec = "M2 = Mp([2, 2]); net = M2**3"
         outputs = specs.create_net(spec, inputs)
         self.assertEqual(outputs.get_shape().as_list(), [1, 8, 8, 5])
         tf.global_variables_initializer().run()
         result = outputs.eval()
         self.assertEqual(tuple(result.shape), (1, 8, 8, 5))
         self.assertEqual(summaries.tf_spec_structure(spec, inputs),
                          "_ maxpool maxpool maxpool")
Exemplo n.º 3
0
 def testImport(self):
     with self.test_session():
         inputs = tf.constant(_rand(10, 20))
         spec = "S = Import('import tensorflow as tf; f = tf.nn.sigmoid')"
         spec += "; net = S | S"
         outputs = specs.create_net(spec, inputs)
         self.assertEqual(outputs.get_shape().as_list(), [10, 20])
         tf.global_variables_initializer().run()
         result = outputs.eval()
         self.assertEqual(tuple(result.shape), (10, 20))
         self.assertEqual(summaries.tf_spec_structure(spec, inputs),
                          "_ sig sig")
Exemplo n.º 4
0
 def testAdd(self):
     with self.test_session():
         inputs = tf.constant(_rand(17, 55))
         spec = "net = Fs(10) + Fr(10)"
         outputs = specs.create_net(spec, inputs)
         self.assertEqual(outputs.get_shape().as_list(), [17, 10])
         tf.global_variables_initializer().run()
         result = outputs.eval()
         self.assertEqual(tuple(result.shape), (17, 10))
         self.assertEqual(
             summaries.tf_spec_structure(spec, inputs),
             "_ var dot var biasadd sig "
             "<> var dot var biasadd relu add")
Exemplo n.º 5
0
 def testConc(self):
     with self.test_session():
         inputs = tf.constant(_rand(10, 20))
         spec = "net = Conc(1, Fs(20), Fs(10))"
         outputs = specs.create_net(spec, inputs)
         self.assertEqual(outputs.get_shape().as_list(), [10, 30])
         tf.global_variables_initializer().run()
         result = outputs.eval()
         self.assertEqual(tuple(result.shape), (10, 30))
         self.assertEqual(
             summaries.tf_spec_structure(spec, inputs),
             "_ _ var dot var biasadd sig "
             "<> var dot var biasadd sig concat")
Exemplo n.º 6
0
 def testAbbrevPower(self):
     with self.test_session():
         inputs = tf.constant(_rand(1, 64, 64, 5))
         spec = "C3 = Cr([3, 3]); M2 = Mp([2, 2]); net = (C3(5) | M2)**3"
         outputs = specs.create_net(spec, inputs)
         self.assertEqual(outputs.get_shape().as_list(), [1, 8, 8, 5])
         tf.global_variables_initializer().run()
         result = outputs.eval()
         self.assertEqual(tuple(result.shape), (1, 8, 8, 5))
         self.assertEqual(
             summaries.tf_spec_structure(spec, inputs),
             "_ var conv var biasadd relu maxpool var conv var"
             " biasadd relu maxpool var conv var"
             " biasadd relu maxpool")
Exemplo n.º 7
0
 def testAutoFunction(self):
     with self.test_session():
         inputs = tf.constant(_rand(1, 18, 19, 5))
         with specs.ops:
             # pylint: disable=undefined-variable
             net = SL.conv2d(64, 5)
         outputs = net.funcall(inputs)
         self.assertEqual(outputs.get_shape().as_list(), [1, 18, 19, 64])
         tf.global_variables_initializer().run()
         result = outputs.eval()
         self.assertEqual(tuple(result.shape), (1, 18, 19, 64))
         self.assertEqual(
             summaries.tf_spec_structure("net = Cr(64, 5)", inputs),
             "_ var conv var biasadd relu")