我嘗試使用以下方法加載模型和圖形:saver = tf.train.import_meta_graph(tf.train.latest_checkpoint(model_path)+".meta")graph = tf.get_default_graph()outputs = graph.get_tensor_by_name('output:0')outputs = tf.cast(outputs,dtype=tf.float32)X = graph.get_tensor_by_name('input:0')sess = tf.Session()sess.run(tf.global_variables_initializer()) sess.run(tf.local_variables_initializer()) if(tf.train.checkpoint_exists(tf.train.latest_checkpoint(model_path))): saver.restore(sess, tf.train.latest_checkpoint(model_path)) print(tf.train.latest_checkpoint(model_path) + "Session Loaded for Testing") 它有效!...但是當我嘗試運行會話時,出現以下錯誤:y_test_output= sess.run(outputs, feed_dict={X: x_test})錯誤是:Caused by op 'output', defined at: File "testing_reality.py", line 21, in <module> saver = tf.train.import_meta_graph(tf.train.latest_checkpoint(model_path)+".meta") File "C:\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1674, in import_meta_graph meta_graph_or_file, clear_devices, import_scope, **kwargs)[0] File "C:\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1696, in _import_meta_graph_with_return_elements **kwargs)) File "C:\Python35\lib\site-packages\tensorflow\python\framework\meta_graph.py", line 806, in import_scoped_meta_graph_with_return_elements return_elements=return_elements) File "C:\Python35\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func return func(*args, **kwargs)不明白是什么問題給我造成了這個問題。請幫我獲取丟失的鏈接。我檢查過:>>> outputs<tf.Tensor 'output:0' shape=(?, 1) dtype=float32>仍然無法理解錯誤的原因。我在 Windows 10 操作系統上使用最新版本的 Tensorflow '1.12.0'。
由于張量數據類型和形狀 Tensorflow,運行會話失敗
慕田峪7331174
2021-10-26 10:23:37