亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

由于張量數據類型和形狀 Tensorflow,運行會話失敗

由于張量數據類型和形狀 Tensorflow,運行會話失敗

慕田峪7331174 2021-10-26 10:23:37
我嘗試使用以下方法加載模型和圖形: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'。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 188 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號