保存したチェックポイントからglobal_step
を取得できないようです。私のコード:Tensorflowはチェックポイントからglobal_stepを復元できません
//(...)
checkpoint_file = tf.train.latest_checkpoint(checkpoint_dir)
saver = tf.train.import_meta_graph("{}.meta".format(checkpoint_file), clear_devices=True)
saver.restore(sess, checkpoint_file)
for v in tf.global_variables():
print(v)
test = tf.get_variable("global_step")
print(test)
結果:
//(...)
Tensor("global_step/read:0", shape=(), dtype=int32)
//(...)
Traceback (most recent call last):
File "train.py", line XXX, in <module>
test = tf.get_variable("global_step")
File "(...)/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 988, in get_variable
custom_getter=custom_getter)
File "(...)/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 890, in get_variable
custom_getter=custom_getter)
File "(...)/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 348, in get_variable
validate_shape=validate_shape)
File "(...)/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 333, in _true_getter
caching_device=caching_device, validate_shape=validate_shape)
File "(...)/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 660, in _get_single_variable
"but instead was +1ms." % (name, shape))
ValueError: Shape of a new variable (global_step) must be fully defined, but instead was <unknown>.
私もglobal_step:0
とが、同じ結果と試みました。任意のヒント?またはtf.get_variable
を使用しないでください。
は、その変数が最初の場所でtf.get_variable
で作成された場合にのみ、既存の変数を取得するためにtf.get_variable
を使用することができますあなたの