0
我已經創造了Keras一個模型,然後我初始化通過調用節能模式和初始化中Keras
session=tf.Session()
session.run(tf.global_variables_initializer())
訓練結束後,我試圖通過運行
saver = tf.train.Saver()
saver.save(session, "action_inference_cart_pole_plan16_5000episode.ckpt")
但是保存模型,它不斷返回這個錯誤
FailedPreconditionError: Attempting to use uninitialized value dense_241/kernel
[[Node: dense_241/kernel/_21554 = _Send[T=DT_FLOAT, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_1854_dense_241/kernel", _device="/job:localhost/replica:0/task:0/gpu:0"](dense_241/kernel)]]
[[Node: dense_284/bias/_21741 = _Recv[_start_time=0, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_1947_dense_284/bias", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](^_arg_save_15/Const_0_0, ^save_15/SaveV2/tensor_names, ^save_15/SaveV2/shape_and_slices)]]
我試圖手動初始化失敗的變量,曾經工作過一次。但是,現在有不同的變量,我甚至找不到它們。我想了解爲什麼會發生這種情況。
下面是完整的代碼
https://gist.github.com/guillefix/4c20284ca1e0d87dfab1dfde11ef9ea6
您可以添加代碼,請一個例子(從keras documentation複製)? – Nain
我用代碼添加了一個要點鏈接 – guillefix