1
我正在嘗試啓動分佈式Tensorflow並獲取以下錯誤。 我的代碼如下所示:Tensorflow - 圖已完成,無法修改
sv = tf.train.Supervisor(is_chief=(task_index == 0), logdir="/tmp/train_logs", init_op=init_op,
summary_op=summary_op, saver=saver, global_step=global_step, save_model_secs=600)
with sv.managed_session(server.target) as sess:
step = 0
while not sv.should_stop() and step < nnc.steps:
mini_batches = random_mini_batches(x_train, y_train, mini_batch_size)
for mini_batch in mini_batches:
(batch_x, batch_y) = mini_batch
_, step = sess.run([train_op, global_step], feed_dict={x: batch_x, y: batch_y})
當我得到它的失敗上random_mini_batches
函數的錯誤。 但我完全不明白如何以及爲什麼。 random_mini_batches
函數是一個用純python + numpy編寫的函數,沒有任何與TensorFlow相關的東西。之前未使用x_train
和y_train
。
這裏是我的錯誤:
File "/Users/curr_user/PycharmProjects/curr_project/src/nn.py", line 36, in random_mini_batches
num_complete_minibatches = int(math.floor(m/mini_batch_size)) # number of mini batches of size mini_batch_size
File "/Users/curr_user/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 880, in r_binary_op_wrapper
x = ops.convert_to_tensor(x, dtype=y.dtype.base_dtype, name="x")
File "/Users/curr_user/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 611, in convert_to_tensor
as_ref=False)
File "/Users/curr_user/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 676, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/Users/curr_user/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 121, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/Users/curr_user/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 106, in constant
attrs={"value": tensor_value, "dtype": dtype_value}, name=name).outputs[0]
File "/Users/curr_user/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2582, in create_op
self._check_not_finalized()
File "/Users/curr_user/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2290, in _check_not_finalized
raise RuntimeError("Graph is finalized and cannot be modified.")
任何幫助,將不勝感激! 謝謝
謝謝,看起來你是對的。 – user3489820