最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

關(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)致不同編輯器編碼解碼不一致,會報錯。所以唯一的辦法全程用

一個編輯器去寫,保存?;蛘弑WC都是用一種方式編碼解碼就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)文章

  • Python -m參數(shù)原理及使用方法解析

    Python -m參數(shù)原理及使用方法解析

    這篇文章主要介紹了Python -m參數(shù)原理及使用方法解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-08-08
  • python實現(xiàn)保存網(wǎng)頁到本地示例

    python實現(xiàn)保存網(wǎng)頁到本地示例

    這篇文章主要介紹了python實現(xiàn)保存網(wǎng)頁到本地示例,需要的朋友可以參考下
    2014-03-03
  • Python3使用Selenium獲取session和token方法詳解

    Python3使用Selenium獲取session和token方法詳解

    這篇文章主要介紹了Python3使用Selenium獲取session和token方法詳解,需要的朋友可以參考下
    2021-02-02
  • Python進(jìn)度條tqdm的用法詳解

    Python進(jìn)度條tqdm的用法詳解

    這篇文章主要介紹了Python進(jìn)度條tqdm的用法,這對于第三方庫非常豐富的Python來說,想要實現(xiàn)這一功能并不是什么難事,本文通過實例代碼給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧
    2021-08-08
  • Python三元運算與lambda表達(dá)式實例解析

    Python三元運算與lambda表達(dá)式實例解析

    這篇文章主要介紹了Python三元運算與lambda表達(dá)式實例解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-11-11
  • python用glob模塊匹配路徑的方法詳解

    python用glob模塊匹配路徑的方法詳解

    這篇文章主要介紹了python如何用glob模塊匹配路徑,glob模塊是Python的一個標(biāo)準(zhǔn)庫,用于在文件系統(tǒng)中查找文件名匹配特定模式的文件路徑,需要的朋友可以參考下
    2024-02-02
  • python使用numpy尋找二維數(shù)組的最值及其下標(biāo)方法分析

    python使用numpy尋找二維數(shù)組的最值及其下標(biāo)方法分析

    這篇文章主要為大家介紹了python使用numpy尋找二維數(shù)組的最值及其下標(biāo)實現(xiàn)方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • R vs. Python 數(shù)據(jù)分析中誰與爭鋒?

    R vs. Python 數(shù)據(jù)分析中誰與爭鋒?

    R和Python兩者誰更適合數(shù)據(jù)分析領(lǐng)域?在某些特定情況下誰會更有優(yōu)勢?還是一個天生在各方面都比另一個更好?
    2017-10-10
  • 新建文件時Pycharm中自動設(shè)置頭部模板信息的方法

    新建文件時Pycharm中自動設(shè)置頭部模板信息的方法

    這篇文章主要介紹了新建文件時Pycharm中自動設(shè)置頭部模板信息的方法,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-04-04
  • Django之模板層的實現(xiàn)代碼

    Django之模板層的實現(xiàn)代碼

    這篇文章主要介紹了Django之模板層的實現(xiàn)代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09

最新評論

吉安县| 东乡族自治县| 略阳县| 泸州市| 江川县| 鹤岗市| 上栗县| 麟游县| 弥勒县| 汉阴县| 双流县| 三明市| 怀集县| 介休市| 永靖县| 乳山市| 灯塔市| 凤庆县| 噶尔县| 衡东县| 河西区| 昭平县| 海淀区| 麻栗坡县| 平邑县| 谢通门县| 宜黄县| 石首市| 河北区| 侯马市| 富源县| 嘉善县| 佳木斯市| 鹤山市| 珠海市| 响水县| 柳州市| 玉溪市| 尼玛县| 甘谷县| 肥西县|