def testFunctionalConv2DNoReuse(self):
   height, width = 7, 9
   images = random_ops.random_uniform((5, height, width, 3), seed=1)
   conv_layers.separable_conv2d(images, 32, [3, 3])
   self.assertEqual(len(variables.trainable_variables()), 3)
   conv_layers.separable_conv2d(images, 32, [3, 3])
   self.assertEqual(len(variables.trainable_variables()), 6)
 def testFunctionalConv2DNoReuse(self):
     height, width = 7, 9
     images = random_ops.random_uniform((5, height, width, 3), seed=1)
     conv_layers.separable_conv2d(images, 32, [3, 3])
     self.assertEqual(len(variables.trainable_variables()), 3)
     conv_layers.separable_conv2d(images, 32, [3, 3])
     self.assertEqual(len(variables.trainable_variables()), 6)
    def testInvalidKernelSize(self):
        height, width = 7, 9
        images = random_ops.random_uniform((5, height, width, 3), seed=1)
        with self.assertRaisesRegexp(ValueError, 'kernel_size'):
            conv_layers.separable_conv2d(images, 32, (1, 2, 3))

        with self.assertRaisesRegexp(ValueError, 'kernel_size'):
            conv_layers.separable_conv2d(images, 32, None)
    def testInvalidStrides(self):
        height, width = 7, 9
        images = random_ops.random_uniform((5, height, width, 3), seed=1)
        with self.assertRaisesRegexp(ValueError, 'strides'):
            conv_layers.separable_conv2d(images, 32, 3, strides=(1, 2, 3))

        with self.assertRaisesRegexp(ValueError, 'strides'):
            conv_layers.separable_conv2d(images, 32, 3, strides=None)
  def testInvalidKernelSize(self):
    height, width = 7, 9
    images = random_ops.random_uniform((5, height, width, 3), seed=1)
    with self.assertRaisesRegexp(ValueError, 'kernel_size'):
      conv_layers.separable_conv2d(images, 32, (1, 2, 3))

    with self.assertRaisesRegexp(ValueError, 'kernel_size'):
      conv_layers.separable_conv2d(images, 32, None)
  def testInvalidStrides(self):
    height, width = 7, 9
    images = random_ops.random_uniform((5, height, width, 3), seed=1)
    with self.assertRaisesRegexp(ValueError, 'strides'):
      conv_layers.separable_conv2d(images, 32, 3, strides=(1, 2, 3))

    with self.assertRaisesRegexp(ValueError, 'strides'):
      conv_layers.separable_conv2d(images, 32, 3, strides=None)
 def testFunctionalConv2DReuseFromScope(self):
     with variable_scope.variable_scope('scope'):
         height, width = 7, 9
         images = random_ops.random_uniform((5, height, width, 3), seed=1)
         conv_layers.separable_conv2d(images, 32, [3, 3], name='sepconv1')
         self.assertEqual(len(variables.trainable_variables()), 3)
     with variable_scope.variable_scope('scope', reuse=True):
         conv_layers.separable_conv2d(images, 32, [3, 3], name='sepconv1')
         self.assertEqual(len(variables.trainable_variables()), 3)
 def testFunctionalConv2DReuseFromScope(self):
   with variable_scope.variable_scope('scope'):
     height, width = 7, 9
     images = random_ops.random_uniform((5, height, width, 3), seed=1)
     conv_layers.separable_conv2d(images, 32, [3, 3], name='sepconv1')
     self.assertEqual(len(variables.trainable_variables()), 3)
   with variable_scope.variable_scope('scope', reuse=True):
     conv_layers.separable_conv2d(images, 32, [3, 3], name='sepconv1')
     self.assertEqual(len(variables.trainable_variables()), 3)
 def testFunctionalConv2DNoReuse(self):
   height, width = 7, 9
   images = random_ops.random_uniform((5, height, width, 3), seed=1)
   conv_layers.separable_conv2d(images, 32, [3, 3])
   self.assertEqual(
       len(ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES)), 3)
   conv_layers.separable_conv2d(images, 32, [3, 3])
   self.assertEqual(
       len(ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES)), 6)
Esempio n. 10
0
 def testFunctionalConv2DInitializerFromScope(self):
   with self.test_session() as sess:
     with variable_scope.variable_scope(
         'scope', initializer=init_ops.ones_initializer()):
       height, width = 7, 9
       images = random_ops.random_uniform((5, height, width, 3), seed=1)
       conv_layers.separable_conv2d(images, 32, [3, 3], name='sepconv1')
       weights = variables.trainable_variables()
       # Check the names of weights in order.
       self.assertTrue('depthwise_kernel' in weights[0].name)
       self.assertTrue('pointwise_kernel' in weights[1].name)
       self.assertTrue('bias' in weights[2].name)
       sess.run(variables.global_variables_initializer())
       weights = sess.run(weights)
       # Check that the kernel weights got initialized to ones (from scope)
       self.assertAllClose(weights[0], np.ones((3, 3, 3, 1)))
       self.assertAllClose(weights[1], np.ones((1, 1, 3, 32)))
       # Check that the bias still got initialized to zeros.
       self.assertAllClose(weights[2], np.zeros((32)))
Esempio n. 11
0
 def testFunctionalConv2DInitializerFromScope(self):
   with self.test_session() as sess:
     with variable_scope.variable_scope(
         'scope', initializer=init_ops.ones_initializer()):
       height, width = 7, 9
       images = random_ops.random_uniform((5, height, width, 3), seed=1)
       conv_layers.separable_conv2d(images, 32, [3, 3], name='sepconv1')
       weights = variables.trainable_variables()
       # Check the names of weights in order.
       self.assertTrue('depthwise_kernel' in weights[0].name)
       self.assertTrue('pointwise_kernel' in weights[1].name)
       self.assertTrue('bias' in weights[2].name)
       sess.run(variables.global_variables_initializer())
       weights = sess.run(weights)
       # Check that the kernel weights got initialized to ones (from scope)
       self.assertAllClose(weights[0], np.ones((3, 3, 3, 1)))
       self.assertAllClose(weights[1], np.ones((1, 1, 3, 32)))
       # Check that the bias still got initialized to zeros.
       self.assertAllClose(weights[2], np.zeros((32)))
Esempio n. 12
0
 def testInvalidDataFormat(self):
     height, width = 7, 9
     images = random_ops.random_uniform((5, height, width, 3), seed=1)
     with self.assertRaisesRegexp(ValueError, 'data_format'):
         conv_layers.separable_conv2d(images, 32, 3, data_format='invalid')
Esempio n. 13
0
 def testInvalidDataFormat(self):
   height, width = 7, 9
   images = random_ops.random_uniform((5, height, width, 3), seed=1)
   with self.assertRaisesRegexp(ValueError, 'data_format'):
     conv_layers.separable_conv2d(images, 32, 3, data_format='invalid')