欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

關(guān)于TensorFlow新舊版本函數(shù)接口變化詳解

 更新時間:2020年02月10日 17:44:22   作者:furuit  
今天小編就為大家分享一篇關(guān)于TensorFlow新舊版本函數(shù)接口變化詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

TensorFlow版本更新太快 了,所以導(dǎo)致一些以前接口函數(shù)不一致,會報錯。

這里總結(jié)了一下自己犯的錯,以防以后再碰到,也可以給別人參考。

首先我的cifar10的代碼都是找到當(dāng)前最新的tf官網(wǎng)給的,所以后面還有新的tf出來改動了的話,可能又會失效了。

1.python3:(unicode error) 'utf-8' codec can't decode

剛開始執(zhí)行的時候就報這個錯,很郁悶后來發(fā)現(xiàn)是因為我用多個編輯器編寫,

保存。導(dǎo)致不同編輯器編碼解碼不一致,會報錯。所以唯一的辦法全程用

一個編輯器去寫,保存。或者保證都是用一種方式編碼解碼就OK了

一:Tersorflow CIFAR-10 訓(xùn)練示例報錯及解決方案(1)
 
1.AttributeError:'module' object has noattribute 'random_crop'
 
##解決方案:
 
將distorted_image= tf.image.random_crop(reshaped_image,[height, width])改為:
 
distorted_image = tf.random_crop(reshaped_image,[height,width,3])
 
 
 
2. AttributeError:'module'object has no attribute 'SummaryWriter'
 
##解決方案:tf.train.SummaryWriter改為:tf.summary.FileWriter
 
 
 
3. AttributeError:'module'object has no attribute 'summaries'
 
解決方案: tf.merge_all_summaries()改為:summary_op =tf.summaries.merge_all()
 
 
 
4. AttributeError: 'module' object hasno attribute'histogram_summary
 
tf.histogram_summary(var.op.name,var)改為: tf.summaries.histogram()
 
 
 
5. AttributeError: 'module' object hasno attribute'scalar_summary'
 
tf.scalar_summary(l.op.name+ ' (raw)', l)
 
##解決方案:
 
tf.scalar_summary('images',images)改為:tf.summary.scalar('images', images)
 
tf.image_summary('images',images)改為:tf.summary.image('images', images)
 
 
 
6. ValueError: Only call`softmax_cross_entropy_with_logits` withnamed arguments (labels=...,logits=..., ...)
 
##解決方案:
 
 cifar10.loss(labels, logits) 改為:cifar10.loss(logits=logits,labels=labels)
 
 cross_entropy=tf.nn.softmax_cross_entropy_with_logits(logits,dense_labels,name='cross_entropy_per_example')
 
改為:
 
 cross_entropy =tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=dense_labels,name='cross_entropy_per_example')
 
 
 
7. TypeError: Using a `tf.Tensor` as a Python `bool`isnot allowed. Use `if t is not None:` instead of `if t:` to test if a tensorisdefined, and use TensorFlow ops such as tf.cond to execute subgraphsconditionedon the value of a tensor.
 
##解決方案:
 
if grad: 改為 if grad is not None:
 
 
 
8. ValueError: Shapes (2, 128, 1) and () are incompatible
 
###解決方案:
 
concated = tf.concat(1, [indices, sparse_labels])改為:
 
concated= tf.concat([indices, sparse_labels], 1)
 
 
 
9. 報錯:(這個暫時沒有遇到)
 
File"/home/lily/work/Tensorflow/CIRFAR-10/tensorflow.cifar10-master/cifar10_input.py",line83, in read_cifar10
 
  result.key, value=reader.read(filename_queue)
 
 File"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/io_ops.py",line326, in read
 
queue_ref = queue.queue_ref
 
AttributeError: 'str' object hasno attribute 'queue_ref'
 
###解決方案:
 
由于訓(xùn)練樣本的路徑需要修改,給cifar10_input.py中data_dir賦值為本地數(shù)據(jù)所在的文件夾
 

二:Tersorflow CIFAR-10 訓(xùn)練示例報錯及解決方案

1,F(xiàn)ile"tensorflow/models/slim/preprocessing/cifarnet_preproces.py", line70, in preprocess_for_train
return tf.image.per_image_whitening(distorted_image)
AttributeError: 'module' object has no attribute'per_image_whitening'

以上這篇關(guān)于TensorFlow新舊版本函數(shù)接口變化詳解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 在linux系統(tǒng)下安裝python librtmp包的實現(xiàn)方法

    在linux系統(tǒng)下安裝python librtmp包的實現(xiàn)方法

    今天小編就為大家分享一篇在linux系統(tǒng)下安裝python librtmp包的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-07-07
  • 使用matplotlib的pyplot模塊繪圖的實現(xiàn)示例

    使用matplotlib的pyplot模塊繪圖的實現(xiàn)示例

    這篇文章主要介紹了使用matplotlib的pyplot模塊繪圖的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • python簡單構(gòu)建可用IP代理池

    python簡單構(gòu)建可用IP代理池

    這篇文章主要介紹了python構(gòu)建簡單可以代理池,實現(xiàn)過程匹配ip:port的正則表達(dá)式、匹配出所有的ip與端口,放入列表、判斷爬取的代理ip是否可用、使用代理ip訪問指定網(wǎng)站,具體實現(xiàn)需要的小伙伴可以參考下面文章內(nèi)容
    2022-02-02
  • 感知器基礎(chǔ)原理及python實現(xiàn)過程詳解

    感知器基礎(chǔ)原理及python實現(xiàn)過程詳解

    這篇文章主要介紹了感知器基礎(chǔ)原理及python實現(xiàn)過程詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-09-09
  • 使用Selenium破解新浪微博的四宮格驗證碼

    使用Selenium破解新浪微博的四宮格驗證碼

    今天小編就為大家分享一篇關(guān)于使用Selenium破解新浪微博的四宮格驗證碼的文章,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • python指定路徑斜杠與反斜杠遇到的問題

    python指定路徑斜杠與反斜杠遇到的問題

    這篇文章主要介紹了python指定路徑斜杠與反斜杠遇到的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • 利用LyScript實現(xiàn)應(yīng)用層鉤子掃描器

    利用LyScript實現(xiàn)應(yīng)用層鉤子掃描器

    Capstone 是一個輕量級的多平臺、多架構(gòu)的反匯編框架。本篇文章將運用LyScript插件結(jié)合Capstone反匯編引擎實現(xiàn)一個鉤子掃描器,感興趣的可以了解一下
    2022-08-08
  • Python DNS查詢放大攻擊實現(xiàn)原理解析

    Python DNS查詢放大攻擊實現(xiàn)原理解析

    這篇文章主要介紹了Python DNS查詢放大攻擊實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-10-10
  • python和numpy?matplotlib版本匹配及安裝指定版本庫

    python和numpy?matplotlib版本匹配及安裝指定版本庫

    Matplotlib 是 Python 的繪圖庫,它經(jīng)常與NumPy一起使用,從而提供一種能夠代替Matlab的方案,這篇文章主要給大家介紹了關(guān)于python和numpy?matplotlib版本匹配及安裝指定版本庫的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2023-10-10
  • python使用knn實現(xiàn)特征向量分類

    python使用knn實現(xiàn)特征向量分類

    這篇文章主要為大家詳細(xì)介紹了python使用knn實現(xiàn)特征向量分類,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-12-12

最新評論