Skip to content

Commit 95b1cba

Browse files
chuyang-dengnadiaya
authored andcommitted
fix: update scripts to support tf-2.0 (#250)
1 parent 8a1d656 commit 95b1cba

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

test/resources/gpu_device_placement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
2020
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
2121
c = tf.matmul(a, b)
22-
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
22+
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))
2323
# Runs the op.
2424
print(sess.run(c))
2525
print('-' * 87)

test/resources/keras_inception.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
model = keras.applications.inception_v3.InceptionV3(weights='imagenet')
2727

2828
# Exports the keras model as TensorFlow Serving Saved Model
29-
with tf.Session() as session:
29+
with tf.compat.v1.Session() as session:
3030

31-
init = tf.global_variables_initializer()
31+
init = tf.compat.v1.global_variables_initializer()
3232
session.run(init)
3333

34-
tf.saved_model.simple_save(
34+
tf.compat.v1.saved_model.simple_save(
3535
session,
3636
os.path.join(args.model_dir, 'inception-model/1'),
3737
inputs={'input_image': model.input},

test/resources/mnist/horovod_mnist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
config = tf.compat.v1.ConfigProto()
3333
config.gpu_options.allow_growth = True
3434
config.gpu_options.visible_device_list = str(hvd.local_rank())
35-
K.set_session(tf.Session(config=config))
35+
K.set_session(tf.compat.v1.Session(config=config))
3636

3737
batch_size = 128
3838
num_classes = 10
@@ -119,10 +119,10 @@
119119
# Exports the keras model as TensorFlow Serving Saved Model
120120
with K.get_session() as session:
121121

122-
init = tf.global_variables_initializer()
122+
init = tf.compat.v1.global_variables_initializer()
123123
session.run(init)
124124

125-
tf.saved_model.simple_save(
125+
tf.compat.v1.saved_model.simple_save(
126126
session,
127127
os.path.join('/opt/ml/model/mnist/1'),
128128
inputs={'input_image': model.input},

0 commit comments

Comments
 (0)