Browse Source

Changed deprecated tf.initialize_all_variables() to tf.global_variables_initializer()

Joshua Howard 8 years ago
parent
commit
31f1af580a

+ 1 - 1
autoencoder/autoencoder_models/Autoencoder.py

@@ -21,7 +21,7 @@ class Autoencoder(object):
         self.cost = 0.5 * tf.reduce_sum(tf.pow(tf.sub(self.reconstruction, self.x), 2.0))
         self.optimizer = optimizer.minimize(self.cost)
 
-        init = tf.initialize_all_variables()
+        init = tf.global_variables_initializer()
         self.sess = tf.Session()
         self.sess.run(init)
 

+ 2 - 2
autoencoder/autoencoder_models/DenoisingAutoencoder.py

@@ -25,7 +25,7 @@ class AdditiveGaussianNoiseAutoencoder(object):
         self.cost = 0.5 * tf.reduce_sum(tf.pow(tf.sub(self.reconstruction, self.x), 2.0))
         self.optimizer = optimizer.minimize(self.cost)
 
-        init = tf.initialize_all_variables()
+        init = tf.global_variables_initializer()
         self.sess = tf.Session()
         self.sess.run(init)
 
@@ -92,7 +92,7 @@ class MaskingNoiseAutoencoder(object):
         self.cost = 0.5 * tf.reduce_sum(tf.pow(tf.sub(self.reconstruction, self.x), 2.0))
         self.optimizer = optimizer.minimize(self.cost)
 
-        init = tf.initialize_all_variables()
+        init = tf.global_variables_initializer()
         self.sess = tf.Session()
         self.sess.run(init)
 

+ 1 - 1
autoencoder/autoencoder_models/VariationalAutoencoder.py

@@ -30,7 +30,7 @@ class VariationalAutoencoder(object):
         self.cost = tf.reduce_mean(reconstr_loss + latent_loss)
         self.optimizer = optimizer.minimize(self.cost)
 
-        init = tf.initialize_all_variables()
+        init = tf.global_variables_initializer()
         self.sess = tf.Session()
         self.sess.run(init)
 

+ 1 - 1
differential_privacy/dp_sgd/dp_mnist/dp_mnist.py

@@ -344,7 +344,7 @@ def Train(mnist_train_file, mnist_test_file, network_parameters, num_steps,
     # We need to maintain the intialization sequence.
     for v in tf.trainable_variables():
       sess.run(tf.initialize_variables([v]))
-    sess.run(tf.initialize_all_variables())
+    sess.run(tf.global_variables_initializer())
     sess.run(init_ops)
 
     results = []

+ 1 - 1
differential_privacy/multiple_teachers/deep_cnn.py

@@ -490,7 +490,7 @@ def train(images, labels, ckpt_path, dropout=False):
     print("Graph constructed and saver created")
 
     # Build an initialization operation to run below.
-    init = tf.initialize_all_variables()
+    init = tf.global_variables_initializer()
 
     # Create and init sessions
     sess = tf.Session(config=tf.ConfigProto(log_device_placement=FLAGS.log_device_placement)) #NOLINT(long-line)

+ 1 - 1
differential_privacy/privacy_accountant/tf/accountant.py

@@ -124,7 +124,7 @@ class MomentsAccountant(object):
   """Privacy accountant which keeps track of moments of privacy loss.
 
   Note: The constructor of this class creates tf.Variables that must
-  be initialized with tf.initialize_all_variables() or similar calls.
+  be initialized with tf.global_variables_initializer() or similar calls.
 
   MomentsAccountant accumulates the high moments of the privacy loss. It
   requires a method for computing differenital moments of the noise (See

+ 1 - 1
inception/inception/inception_distributed_train.py

@@ -236,7 +236,7 @@ def train(target, dataset, cluster_spec):
       summary_op = tf.merge_all_summaries()
 
       # Build an initialization operation to run below.
-      init_op = tf.initialize_all_variables()
+      init_op = tf.global_variables_initializer()
 
       # We run the summaries in the same thread as the training operations by
       # passing in None for summary_op to avoid a summary_thread being started.

+ 1 - 1
inception/inception/inception_train.py

@@ -307,7 +307,7 @@ def train(dataset):
     summary_op = tf.merge_summary(summaries)
 
     # Build an initialization operation to run below.
-    init = tf.initialize_all_variables()
+    init = tf.global_variables_initializer()
 
     # Start running operations on the Graph. allow_soft_placement must be set to
     # True to build towers on GPU, as some of the ops do not have GPU

+ 3 - 3
inception/inception/slim/inception_test.py

@@ -95,7 +95,7 @@ class InceptionTest(tf.test.TestCase):
       self.assertListEqual(logits.get_shape().as_list(),
                            [None, num_classes])
       images = tf.random_uniform((batch_size, height, width, 3))
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEquals(output.shape, (batch_size, num_classes))
 
@@ -108,7 +108,7 @@ class InceptionTest(tf.test.TestCase):
       logits, _ = inception.inception_v3(eval_inputs, num_classes,
                                          is_training=False)
       predictions = tf.argmax(logits, 1)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (batch_size,))
 
@@ -125,7 +125,7 @@ class InceptionTest(tf.test.TestCase):
       logits, _ = inception.inception_v3(eval_inputs, num_classes,
                                          is_training=False)
       predictions = tf.argmax(logits, 1)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (eval_batch_size,))
 

+ 5 - 5
inception/inception/slim/ops_test.py

@@ -128,7 +128,7 @@ class ConvTest(tf.test.TestCase):
       wd = tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)[0]
       self.assertEquals(wd.op.name,
                         'Conv/weights/Regularizer/L2Regularizer/value')
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       self.assertTrue(sess.run(wd) <= 0.01)
 
   def testCreateConvWithoutWD(self):
@@ -254,7 +254,7 @@ class FCTest(tf.test.TestCase):
       wd = tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)[0]
       self.assertEquals(wd.op.name,
                         'FC/weights/Regularizer/L2Regularizer/value')
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       self.assertTrue(sess.run(wd) <= 0.01)
 
   def testCreateFCWithoutWD(self):
@@ -604,7 +604,7 @@ class BatchNormTest(tf.test.TestCase):
         barrier = tf.no_op(name='gradient_barrier')
         output = control_flow_ops.with_dependencies([barrier], output)
       # Initialize all variables
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       moving_mean = variables.get_variables('BatchNorm/moving_mean')[0]
       moving_variance = variables.get_variables('BatchNorm/moving_variance')[0]
       mean, variance = sess.run([moving_mean, moving_variance])
@@ -634,7 +634,7 @@ class BatchNormTest(tf.test.TestCase):
         barrier = tf.no_op(name='gradient_barrier')
         output = control_flow_ops.with_dependencies([barrier], output)
       # Initialize all variables
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       moving_mean = variables.get_variables('BatchNorm/moving_mean')[0]
       moving_variance = variables.get_variables('BatchNorm/moving_variance')[0]
       mean, variance = sess.run([moving_mean, moving_variance])
@@ -668,7 +668,7 @@ class BatchNormTest(tf.test.TestCase):
         barrier = tf.no_op(name='gradient_barrier')
         output = control_flow_ops.with_dependencies([barrier], output)
       # Initialize all variables
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       moving_mean = variables.get_variables('BatchNorm/moving_mean')[0]
       moving_variance = variables.get_variables('BatchNorm/moving_variance')[0]
       mean, variance = sess.run([moving_mean, moving_variance])

+ 1 - 1
namignizer/names.py

@@ -160,7 +160,7 @@ def train(data_dir, checkpoint_path, config):
         with tf.variable_scope("model", reuse=None, initializer=initializer):
             m = NamignizerModel(is_training=True, config=config)
 
-        tf.initialize_all_variables().run()
+        tf.global_variables_initializer().run()
 
         for i in range(config.max_max_epoch):
             lr_decay = config.lr_decay ** max(i - config.max_epoch, 0.0)

+ 1 - 1
neural_gpu/neural_gpu_trainer.py

@@ -377,7 +377,7 @@ def initialize(sess=None):
                    % ckpt.model_checkpoint_path)
     model.saver.restore(sess, ckpt.model_checkpoint_path)
   elif sv is None:
-    sess.run(tf.initialize_all_variables())
+    sess.run(tf.global_variables_initializer())
     data.print_out("Initialized variables (no supervisor mode).")
   elif FLAGS.task < 1 and FLAGS.mem_size > 0:
     # sess.run(model.mem_norm_op)

+ 1 - 1
neural_programmer/model.py

@@ -674,5 +674,5 @@ class Graph():
         use_locking=True)
     self.step = adam.apply_gradients(zip(grads, optimize_params), 
 					global_step=self.global_step)
-    self.init_op = tf.initialize_all_variables()
+    self.init_op = tf.global_variables_initializer()
 

+ 1 - 1
slim/deployment/model_deploy_test.py

@@ -502,7 +502,7 @@ class DeployTest(tf.test.TestCase):
       self.assertEqual(model.train_op.op.name, 'train_op')
 
       with tf.Session() as sess:
-        sess.run(tf.initialize_all_variables())
+        sess.run(tf.global_variables_initializer())
         moving_mean = tf.contrib.framework.get_variables_by_name(
             'moving_mean')[0]
         moving_variance = tf.contrib.framework.get_variables_by_name(

+ 1 - 1
slim/nets/alexnet_test.py

@@ -137,7 +137,7 @@ class AlexnetV2Test(tf.test.TestCase):
     with self.test_session() as sess:
       inputs = tf.random_uniform((batch_size, height, width, 3))
       logits, _ = alexnet.alexnet_v2(inputs)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits)
       self.assertTrue(output.any())
 

+ 3 - 3
slim/nets/inception_resnet_v2_test.py

@@ -95,7 +95,7 @@ class InceptionTest(tf.test.TestCase):
       self.assertListEqual(logits.get_shape().as_list(),
                            [None, num_classes])
       images = tf.random_uniform((batch_size, height, width, 3))
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEquals(output.shape, (batch_size, num_classes))
 
@@ -109,7 +109,7 @@ class InceptionTest(tf.test.TestCase):
                                                 num_classes,
                                                 is_training=False)
       predictions = tf.argmax(logits, 1)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (batch_size,))
 
@@ -127,7 +127,7 @@ class InceptionTest(tf.test.TestCase):
                                                 is_training=False,
                                                 reuse=True)
       predictions = tf.argmax(logits, 1)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (eval_batch_size,))
 

+ 5 - 5
slim/nets/inception_v1_test.py

@@ -140,7 +140,7 @@ class InceptionV1Test(tf.test.TestCase):
                            [batch_size, num_classes])
       pre_pool = end_points['Mixed_5c']
       feed_dict = {inputs: input_np}
-      tf.initialize_all_variables().run()
+      tf.global_variables_initializer().run()
       pre_pool_out = sess.run(pre_pool, feed_dict=feed_dict)
       self.assertListEqual(list(pre_pool_out.shape), [batch_size, 7, 7, 1024])
 
@@ -157,7 +157,7 @@ class InceptionV1Test(tf.test.TestCase):
     images = tf.random_uniform((batch_size, height, width, 3))
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEquals(output.shape, (batch_size, num_classes))
 
@@ -172,7 +172,7 @@ class InceptionV1Test(tf.test.TestCase):
     predictions = tf.argmax(logits, 1)
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (batch_size,))
 
@@ -189,7 +189,7 @@ class InceptionV1Test(tf.test.TestCase):
     predictions = tf.argmax(logits, 1)
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (eval_batch_size,))
 
@@ -201,7 +201,7 @@ class InceptionV1Test(tf.test.TestCase):
                                        spatial_squeeze=False)
 
     with self.test_session() as sess:
-      tf.initialize_all_variables().run()
+      tf.global_variables_initializer().run()
       logits_out = sess.run(logits)
       self.assertListEqual(list(logits_out.shape), [1, 1, 1, num_classes])
 

+ 5 - 5
slim/nets/inception_v2_test.py

@@ -192,7 +192,7 @@ class InceptionV2Test(tf.test.TestCase):
                            [batch_size, num_classes])
       pre_pool = end_points['Mixed_5c']
       feed_dict = {inputs: input_np}
-      tf.initialize_all_variables().run()
+      tf.global_variables_initializer().run()
       pre_pool_out = sess.run(pre_pool, feed_dict=feed_dict)
       self.assertListEqual(list(pre_pool_out.shape), [batch_size, 7, 7, 1024])
 
@@ -209,7 +209,7 @@ class InceptionV2Test(tf.test.TestCase):
     images = tf.random_uniform((batch_size, height, width, 3))
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEquals(output.shape, (batch_size, num_classes))
 
@@ -224,7 +224,7 @@ class InceptionV2Test(tf.test.TestCase):
     predictions = tf.argmax(logits, 1)
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (batch_size,))
 
@@ -241,7 +241,7 @@ class InceptionV2Test(tf.test.TestCase):
     predictions = tf.argmax(logits, 1)
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (eval_batch_size,))
 
@@ -253,7 +253,7 @@ class InceptionV2Test(tf.test.TestCase):
                                        spatial_squeeze=False)
 
     with self.test_session() as sess:
-      tf.initialize_all_variables().run()
+      tf.global_variables_initializer().run()
       logits_out = sess.run(logits)
       self.assertListEqual(list(logits_out.shape), [1, 1, 1, num_classes])
 

+ 5 - 5
slim/nets/inception_v3_test.py

@@ -221,7 +221,7 @@ class InceptionV3Test(tf.test.TestCase):
                            [batch_size, num_classes])
       pre_pool = end_points['Mixed_7c']
       feed_dict = {inputs: input_np}
-      tf.initialize_all_variables().run()
+      tf.global_variables_initializer().run()
       pre_pool_out = sess.run(pre_pool, feed_dict=feed_dict)
       self.assertListEqual(list(pre_pool_out.shape), [batch_size, 8, 8, 2048])
 
@@ -238,7 +238,7 @@ class InceptionV3Test(tf.test.TestCase):
     images = tf.random_uniform((batch_size, height, width, 3))
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEquals(output.shape, (batch_size, num_classes))
 
@@ -253,7 +253,7 @@ class InceptionV3Test(tf.test.TestCase):
     predictions = tf.argmax(logits, 1)
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (batch_size,))
 
@@ -271,7 +271,7 @@ class InceptionV3Test(tf.test.TestCase):
     predictions = tf.argmax(logits, 1)
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (eval_batch_size,))
 
@@ -283,7 +283,7 @@ class InceptionV3Test(tf.test.TestCase):
                                        spatial_squeeze=False)
 
     with self.test_session() as sess:
-      tf.initialize_all_variables().run()
+      tf.global_variables_initializer().run()
       logits_out = sess.run(logits)
       self.assertListEqual(list(logits_out.shape), [1, 1, 1, num_classes])
 

+ 3 - 3
slim/nets/inception_v4_test.py

@@ -175,7 +175,7 @@ class InceptionTest(tf.test.TestCase):
       self.assertListEqual(logits.get_shape().as_list(),
                            [None, num_classes])
       images = tf.random_uniform((batch_size, height, width, 3))
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEquals(output.shape, (batch_size, num_classes))
 
@@ -189,7 +189,7 @@ class InceptionTest(tf.test.TestCase):
                                          num_classes,
                                          is_training=False)
       predictions = tf.argmax(logits, 1)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (batch_size,))
 
@@ -207,7 +207,7 @@ class InceptionTest(tf.test.TestCase):
                                          is_training=False,
                                          reuse=True)
       predictions = tf.argmax(logits, 1)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(predictions)
       self.assertEquals(output.shape, (eval_batch_size,))
 

+ 1 - 1
slim/nets/overfeat_test.py

@@ -137,7 +137,7 @@ class OverFeatTest(tf.test.TestCase):
     with self.test_session() as sess:
       inputs = tf.random_uniform((batch_size, height, width, 3))
       logits, _ = overfeat.overfeat(inputs)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits)
       self.assertTrue(output.any())
 

+ 7 - 7
slim/nets/resnet_v1_test.py

@@ -104,7 +104,7 @@ class ResnetUtilsTest(tf.test.TestCase):
     y4_expected = tf.reshape(y4_expected, [1, n2, n2, 1])
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       self.assertAllClose(y1.eval(), y1_expected.eval())
       self.assertAllClose(y2.eval(), y2_expected.eval())
       self.assertAllClose(y3.eval(), y3_expected.eval())
@@ -145,7 +145,7 @@ class ResnetUtilsTest(tf.test.TestCase):
     y4_expected = y2_expected
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       self.assertAllClose(y1.eval(), y1_expected.eval())
       self.assertAllClose(y2.eval(), y2_expected.eval())
       self.assertAllClose(y3.eval(), y3_expected.eval())
@@ -240,7 +240,7 @@ class ResnetUtilsTest(tf.test.TestCase):
               tf.get_variable_scope().reuse_variables()
               # Feature extraction at the nominal network rate.
               expected = self._stack_blocks_nondense(inputs, blocks)
-              sess.run(tf.initialize_all_variables())
+              sess.run(tf.global_variables_initializer())
               output, expected = sess.run([output, expected])
               self.assertAllClose(output, expected, atol=1e-4, rtol=1e-4)
 
@@ -388,7 +388,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
             # Feature extraction at the nominal network rate.
             expected, _ = self._resnet_small(inputs, None, is_training=False,
                                              global_pool=False)
-            sess.run(tf.initialize_all_variables())
+            sess.run(tf.global_variables_initializer())
             self.assertAllClose(output.eval(), expected.eval(),
                                 atol=1e-4, rtol=1e-4)
 
@@ -407,7 +407,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
                          [None, 1, 1, num_classes])
     images = create_test_input(batch, height, width, 3)
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEqual(output.shape, (batch, 1, 1, num_classes))
 
@@ -422,7 +422,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
                          [batch, None, None, 32])
     images = create_test_input(batch, height, width, 3)
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(output, {inputs: images.eval()})
       self.assertEqual(output.shape, (batch, 3, 3, 32))
 
@@ -441,7 +441,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
                          [batch, None, None, 32])
     images = create_test_input(batch, height, width, 3)
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(output, {inputs: images.eval()})
       self.assertEqual(output.shape, (batch, 9, 9, 32))
 

+ 7 - 7
slim/nets/resnet_v2_test.py

@@ -104,7 +104,7 @@ class ResnetUtilsTest(tf.test.TestCase):
     y4_expected = tf.reshape(y4_expected, [1, n2, n2, 1])
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       self.assertAllClose(y1.eval(), y1_expected.eval())
       self.assertAllClose(y2.eval(), y2_expected.eval())
       self.assertAllClose(y3.eval(), y3_expected.eval())
@@ -145,7 +145,7 @@ class ResnetUtilsTest(tf.test.TestCase):
     y4_expected = y2_expected
 
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       self.assertAllClose(y1.eval(), y1_expected.eval())
       self.assertAllClose(y2.eval(), y2_expected.eval())
       self.assertAllClose(y3.eval(), y3_expected.eval())
@@ -240,7 +240,7 @@ class ResnetUtilsTest(tf.test.TestCase):
               tf.get_variable_scope().reuse_variables()
               # Feature extraction at the nominal network rate.
               expected = self._stack_blocks_nondense(inputs, blocks)
-              sess.run(tf.initialize_all_variables())
+              sess.run(tf.global_variables_initializer())
               output, expected = sess.run([output, expected])
               self.assertAllClose(output, expected, atol=1e-4, rtol=1e-4)
 
@@ -390,7 +390,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
             expected, _ = self._resnet_small(inputs, None,
                                              is_training=False,
                                              global_pool=False)
-            sess.run(tf.initialize_all_variables())
+            sess.run(tf.global_variables_initializer())
             self.assertAllClose(output.eval(), expected.eval(),
                                 atol=1e-4, rtol=1e-4)
 
@@ -409,7 +409,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
                          [None, 1, 1, num_classes])
     images = create_test_input(batch, height, width, 3)
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits, {inputs: images.eval()})
       self.assertEqual(output.shape, (batch, 1, 1, num_classes))
 
@@ -425,7 +425,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
                          [batch, None, None, 32])
     images = create_test_input(batch, height, width, 3)
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(output, {inputs: images.eval()})
       self.assertEqual(output.shape, (batch, 3, 3, 32))
 
@@ -444,7 +444,7 @@ class ResnetCompleteNetworkTest(tf.test.TestCase):
                          [batch, None, None, 32])
     images = create_test_input(batch, height, width, 3)
     with self.test_session() as sess:
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(output, {inputs: images.eval()})
       self.assertEqual(output.shape, (batch, 9, 9, 32))
 

+ 3 - 3
slim/nets/vgg_test.py

@@ -148,7 +148,7 @@ class VGGATest(tf.test.TestCase):
     with self.test_session() as sess:
       inputs = tf.random_uniform((batch_size, height, width, 3))
       logits, _ = vgg.vgg_a(inputs)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits)
       self.assertTrue(output.any())
 
@@ -292,7 +292,7 @@ class VGG16Test(tf.test.TestCase):
     with self.test_session() as sess:
       inputs = tf.random_uniform((batch_size, height, width, 3))
       logits, _ = vgg.vgg_16(inputs)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits)
       self.assertTrue(output.any())
 
@@ -447,7 +447,7 @@ class VGG19Test(tf.test.TestCase):
     with self.test_session() as sess:
       inputs = tf.random_uniform((batch_size, height, width, 3))
       logits, _ = vgg.vgg_19(inputs)
-      sess.run(tf.initialize_all_variables())
+      sess.run(tf.global_variables_initializer())
       output = sess.run(logits)
       self.assertTrue(output.any())
 

+ 2 - 2
slim/slim_walkthough.ipynb

@@ -300,7 +300,7 @@
     "    # This is good for training, but not for testing.\n",
     "    total_loss2 = slim.losses.get_total_loss(add_regularization_losses=True)\n",
     "    \n",
-    "    init_op = tf.initialize_all_variables()\n",
+    "    init_op = tf.global_variables_initializer()\n",
     "    \n",
     "    with tf.Session() as sess:\n",
     "        sess.run(init_op) # Will initialize the parameters with random weights.\n",
@@ -568,7 +568,7 @@
     "    probabilities = tf.nn.softmax(logits)\n",
     "  \n",
     "    # Initialize all the variables (including parameters) randomly.\n",
-    "    init_op = tf.initialize_all_variables()\n",
+    "    init_op = tf.global_variables_initializer()\n",
     "  \n",
     "    with tf.Session() as sess:\n",
     "        # Run the init_op, evaluate the model outputs and print the results:\n",

+ 3 - 3
street/python/vgsl_model_test.py

@@ -180,7 +180,7 @@ class VgslModelTest(tf.test.TestCase):
           filename,
           model_spec='4,0,0,1[Cr5,5,16 Mp3,3 Lfys16 Lfxs16]O0s12',
           mode='train')
-      tf.initialize_all_variables().run(session=sess)
+      tf.global_variables_initializer().run(session=sess)
       coord = tf.train.Coordinator()
       tf.train.start_queue_runners(sess=sess, coord=coord)
       _, step = model.TrainAStep(sess)
@@ -204,7 +204,7 @@ class VgslModelTest(tf.test.TestCase):
           filename,
           model_spec='2,0,0,1[Cr5,5,16 Mp3,3 Lfys16 Lbx100]O1c105',
           mode='train')
-      tf.initialize_all_variables().run(session=sess)
+      tf.global_variables_initializer().run(session=sess)
       coord = tf.train.Coordinator()
       tf.train.start_queue_runners(sess=sess, coord=coord)
       _, step = model.TrainAStep(sess)
@@ -228,7 +228,7 @@ class VgslModelTest(tf.test.TestCase):
           filename,
           model_spec='8,0,0,1[Cr5,5,16 Mp3,3 Lfys16 Lfx64 Lrx64 Lfx64]O1s12',
           mode='train')
-      tf.initialize_all_variables().run(session=sess)
+      tf.global_variables_initializer().run(session=sess)
       coord = tf.train.Coordinator()
       tf.train.start_queue_runners(sess=sess, coord=coord)
       _, step = model.TrainAStep(sess)

+ 1 - 1
street/python/vgslspecs_test.py

@@ -55,7 +55,7 @@ class VgslspecsTest(tf.test.TestCase):
         target_widths = tf.div(self.in_widths, factor).eval()
         target_heights = tf.div(self.in_heights, factor).eval()
         # Run with the 'real' data.
-        tf.initialize_all_variables().run()
+        tf.global_variables_initializer().run()
         res_image, res_widths, res_heights = sess.run(
             [outputs, vgsl.GetLengths(2), vgsl.GetLengths(1)],
             feed_dict={self.ph_image: self.in_image,

+ 1 - 1
transformer/cluttered_mnist.py

@@ -135,7 +135,7 @@ accuracy = tf.reduce_mean(tf.cast(correct_prediction, 'float'))
 # %% We now create a new session to actually perform the initialization the
 # variables:
 sess = tf.Session()
-sess.run(tf.initialize_all_variables())
+sess.run(tf.global_variables_initializer())
 
 
 # %% We'll now train in minibatches and report accuracy, loss:

+ 1 - 1
transformer/example.py

@@ -55,7 +55,7 @@ with tf.variable_scope('spatial_transformer_0'):
 
 # %% Run session
 sess = tf.Session()
-sess.run(tf.initialize_all_variables())
+sess.run(tf.global_variables_initializer())
 y = sess.run(h_trans, feed_dict={x: batch})
 
 # plt.imshow(y[0])

+ 1 - 1
video_prediction/prediction_train.py

@@ -207,7 +207,7 @@ def main(unused_argv):
     saver.restore(sess, FLAGS.pretrained_model)
 
   tf.train.start_queue_runners(sess)
-  sess.run(tf.initialize_all_variables())
+  sess.run(tf.global_variables_initializer())
 
   tf.logging.info('iteration number, cost')