日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

TensorFlow调试常见问题(pycharm)

發布時間:2023/12/15 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 TensorFlow调试常见问题(pycharm) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. RuntimeError: Attempted to use a closed Session.

在pycharm下調用tensorflow庫時,運行出現以下問題:

  • RuntimeError: Attempted to use a closed Session.

  • 解決方法:將STEP=5000開始的程序整體右移,包含在“with”內

可能遇見的問題:python代碼如何整體移動

  • 選中代碼,按下“Tab”鍵即可整體右移
  • 選中代碼,按下“Shift+Tab”鍵即可整體左移

2. AttributeError: module ‘tensorflow’ has no attribute ‘select’

調用tf.select出錯

將tf.select替換為tf.where即可

3. UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte

利用TensorFlow的tf.gfile.FastGFile讀入圖像發生上述錯誤:

原始代碼:

image_raw_data=tf.gfile.FastGFile('anglababy.jpg','r').read()

將’r’修改為’rb’即可

4. python中用plt.imshow()顯示圖像之后,程序就停止運行,必須關掉顯示的圖像才繼續運行

可以將show()寫在進程里,通過調用進程來打開圖片,那么進程的運行狀態就不會影響到主程序的往下執行了

===============================

import threading
import Image
class ThreadClass(threading.Thread):
def run(self):
im=Image.open(‘z.jpg’)
im.show()

print (1)
t = ThreadClass()
t.start()
print (2)
a=input(‘End’)

===============================

運行結果為:先打印出‘1’,然后顯示圖片z.jpg,接著再不關閉圖片的情況下打印出‘2’。
具體應用的時候你根據需要組織代碼。

5. AttributeError: module ‘tensorflow.python.ops.image_ops’ has no attribute ‘per_image_whitening’

TensorFlow對歸一化函數tf.image.per_image_whitening(img_data)進行了修改,變為以下形式:

adjusted = tf.image.per_image_standardization(img_data)

6. ValueError: Tried to convert ‘min_object_covered’ to a tensor and failed. Error: None values not supported.

  • 解決方法:
begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(tf.shape(img_data), bounding_boxes=boxes,min_object_covered=0.1)

7. NameError:name ‘xrange’ is not defined

解決方式:在Python 3中,range()與xrange()合并為range( )

8. tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value matching_filenames

TensorFlow實戰google深度學習框架中,輸入文件隊列的程序中報錯

原因在于:tf.global_variables_initializer().run()

要改為:sess.run([tf.global_variables_initializer(),tf.local_variables_initializer()])

tf.local_variables_initializer():返回一個初始化所有局部變量的操作(Op)。要是你把圖“投放進一個”session中后,你就能夠通過run 這個操作來初始化所有的局部變量,本質相當于variable_initializers(local_variables())

總結

以上是生活随笔為你收集整理的TensorFlow调试常见问题(pycharm)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。