亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

pycharm中TensorFlow調(diào)試常見(jiàn)問(wèn)題小結(jié)

 更新時(shí)間:2021年06月24日 10:20:57   作者:呆呆的貓  
本文主要介紹了在pycharm下調(diào)用tensorflow庫(kù)時(shí)會(huì)出現(xiàn)的問(wèn)題,在本文做個(gè)小結(jié),也給自己留個(gè)筆記,感興趣的可以了解一下

1. RuntimeError: Attempted to use a closed Session.

在pycharm下調(diào)用tensorflow庫(kù)時(shí),運(yùn)行出現(xiàn)以下問(wèn)題:

RuntimeError: Attempted to use a closed Session.

這里寫圖片描述

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

這里寫圖片描述

可能遇見(jiàn)的問(wèn)題:python代碼如何整體移動(dòng)

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

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

調(diào)用tf.select出錯(cuò)

這里寫圖片描述

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

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

利用TensorFlow的tf.gfile.FastGFile讀入圖像發(fā)生上述錯(cuò)誤:

這里寫圖片描述 

原始代碼:

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

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

這里寫圖片描述

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

可以將show()寫在進(jìn)程里,通過(guò)調(diào)用進(jìn)程來(lái)打開圖片,那么進(jìn)程的運(yùn)行狀態(tài)就不會(huì)影響到主程序的往下執(zhí)行了

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')

運(yùn)行結(jié)果為:先打印出‘1',然后顯示圖片z.jpg,接著再不關(guān)閉圖片的情況下打印出‘2'。
具體應(yīng)用的時(shí)候你根據(jù)需要組織代碼。

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

這里寫圖片描述

TensorFlow對(duì)歸一化函數(shù)tf.image.per_image_whitening(img_data)進(jìn)行了修改,變?yōu)橐韵滦问剑?/strong>

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實(shí)戰(zhàn)google深度學(xué)習(xí)框架中,輸入文件隊(duì)列的程序中報(bào)錯(cuò)

這里寫圖片描述

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

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

tf.local_variables_initializer():返回一個(gè)初始化所有局部變量的操作(Op)。要是你把圖“投放進(jìn)一個(gè)”session中后,你就能夠通過(guò)run 這個(gè)操作來(lái)初始化所有的局部變量,本質(zhì)相當(dāng)于variable_initializers(local_variables())

到此這篇關(guān)于pycharm中TensorFlow調(diào)試常見(jiàn)問(wèn)題小結(jié)的文章就介紹到這了,更多相關(guān)TensorFlow調(diào)試問(wèn)題內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論