Ejemplo n.º 1
0
 def testFunctionalConv3DTransposeNoReuse(self):
   depth, height, width = 5, 7, 9
   volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
   conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3])
   self.assertEqual(len(variables.trainable_variables()), 2)
   conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3])
   self.assertEqual(len(variables.trainable_variables()), 4)
Ejemplo n.º 2
0
 def testFunctionalConv3DTransposeNoReuse(self):
   depth, height, width = 5, 7, 9
   volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
   conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3])
   self.assertEqual(len(variables.trainable_variables()), 2)
   conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3])
   self.assertEqual(len(variables.trainable_variables()), 4)
Ejemplo n.º 3
0
  def testInvalidKernelSize(self):
    depth, height, width = 5, 7, 9
    volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
    with self.assertRaisesRegexp(ValueError, 'kernel_size'):
      conv_layers.conv3d_transpose(volumes, 4, (1, 2))

    with self.assertRaisesRegexp(ValueError, 'kernel_size'):
      conv_layers.conv3d_transpose(volumes, 4, None)
Ejemplo n.º 4
0
  def testInvalidStrides(self):
    depth, height, width = 5, 7, 9
    volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
    with self.assertRaisesRegexp(ValueError, 'strides'):
      conv_layers.conv3d_transpose(volumes, 4, 3, strides=(1, 2))

    with self.assertRaisesRegexp(ValueError, 'strides'):
      conv_layers.conv3d_transpose(volumes, 4, 3, strides=None)
Ejemplo n.º 5
0
  def testInvalidKernelSize(self):
    depth, height, width = 5, 7, 9
    volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
    with self.assertRaisesRegexp(ValueError, 'kernel_size'):
      conv_layers.conv3d_transpose(volumes, 4, (1, 2))

    with self.assertRaisesRegexp(ValueError, 'kernel_size'):
      conv_layers.conv3d_transpose(volumes, 4, None)
Ejemplo n.º 6
0
  def testInvalidStrides(self):
    depth, height, width = 5, 7, 9
    volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
    with self.assertRaisesRegexp(ValueError, 'strides'):
      conv_layers.conv3d_transpose(volumes, 4, 3, strides=(1, 2))

    with self.assertRaisesRegexp(ValueError, 'strides'):
      conv_layers.conv3d_transpose(volumes, 4, 3, strides=None)
Ejemplo n.º 7
0
 def testFunctionalConv3DTransposeReuseFromScope(self):
   with variable_scope.variable_scope('scope'):
     depth, height, width = 5, 7, 9
     volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
     conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3], name='deconv1')
     self.assertEqual(len(variables.trainable_variables()), 2)
   with variable_scope.variable_scope('scope', reuse=True):
     conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3], name='deconv1')
     self.assertEqual(len(variables.trainable_variables()), 2)
Ejemplo n.º 8
0
 def testFunctionalConv3DTransposeReuseFromScope(self):
   with variable_scope.variable_scope('scope'):
     depth, height, width = 5, 7, 9
     volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
     conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3], name='deconv1')
     self.assertEqual(len(variables.trainable_variables()), 2)
   with variable_scope.variable_scope('scope', reuse=True):
     conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3], name='deconv1')
     self.assertEqual(len(variables.trainable_variables()), 2)
Ejemplo n.º 9
0
 def testFunctionalConv3DTransposeInitializerFromScope(self):
   with self.test_session() as sess:
     with variable_scope.variable_scope(
         'scope', initializer=init_ops.ones_initializer()):
       depth, height, width = 5, 7, 9
       volumes = random_ops.random_uniform(
           (5, depth, height, width, 32), seed=1)
       conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3], name='deconv1')
       weights = variables.trainable_variables()
       # Check the names of weights in order.
       self.assertTrue('kernel' in weights[0].name)
       self.assertTrue('bias' in weights[1].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, 4, 32)))
       # Check that the bias still got initialized to zeros.
       self.assertAllClose(weights[1], np.zeros((4)))
Ejemplo n.º 10
0
 def testFunctionalConv3DTransposeInitializerFromScope(self):
   with self.test_session() as sess:
     with variable_scope.variable_scope(
         'scope', initializer=init_ops.ones_initializer()):
       depth, height, width = 5, 7, 9
       volumes = random_ops.random_uniform(
           (5, depth, height, width, 32), seed=1)
       conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3], name='deconv1')
       weights = variables.trainable_variables()
       # Check the names of weights in order.
       self.assertTrue('kernel' in weights[0].name)
       self.assertTrue('bias' in weights[1].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, 4, 32)))
       # Check that the bias still got initialized to zeros.
       self.assertAllClose(weights[1], np.zeros((4)))
Ejemplo n.º 11
0
 def testInvalidDataFormat(self):
     depth, height, width = 5, 7, 9
     volumes = random_ops.random_uniform((5, depth, height, width, 32),
                                         seed=1)
     with self.assertRaisesRegexp(ValueError, 'data_format'):
         conv_layers.conv3d_transpose(volumes, 4, 3, data_format='invalid')
Ejemplo n.º 12
0
 def testInvalidDataFormat(self):
   depth, height, width = 5, 7, 9
   volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1)
   with self.assertRaisesRegexp(ValueError, 'data_format'):
     conv_layers.conv3d_transpose(volumes, 4, 3, data_format='invalid')