概要
クラウドサーバでTensorFlowやってみた。
restoreして、global_stepを保存するやつ。
環境
クラウド idcf
linux debian-8.11
tensorflow 1.2
gpu 無し
サンプルコード
import os
import tensorflow as tf
global_step = tf.Variable(0, trainable = False)
saver = tf.train.Saver()
with tf.Session() as sess:
tf.global_variables_initializer().run()
ckpt = tf.train.get_checkpoint_state(os.getcwd())
if ckpt:
print ("restore")
saver.restore(sess, ckpt.model_checkpoint_path)
step = global_step.eval()
else:
step = 0
for i in range(6):
print (step + i)
global_step.assign(step + i).eval()
saver.save(sess, os.getcwd() + "/global_step2.ckpt")