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)
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)
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)
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)
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)
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)
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)
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)
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)))
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)))
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')
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')