国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

手把手解決module ‘tensorflow‘ has no attribute ‘placeholder

這篇具有很好參考價值的文章主要介紹了手把手解決module ‘tensorflow‘ has no attribute ‘placeholder。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

1、問題背景:構建神經(jīng)網(wǎng)絡在加入卷積層時出現(xiàn)報錯

face_recigntion_model.add(Conv2D(32,3,3,input_shape=(IMAGE_SIZE,IMAGE_SIZE,3),activation='relu'))

AttributeError: module 'tensorflow' has no attribute 'placeholder'

2、報錯原因:可能是由于tf.placeholder的版本問題,tf.placeholder是tensorflow1.x版本的東西,tensorflow2.0就不能用了

查看自己的TensorFlow版本print(tf.__version__)

我的為2.8.0,需要降版本

3、解決方法:

方法1:

修改import tensorflow as tf

import tensorflow.compat.v1 as tf

tf.disable_v2_behavior()

方法2:

修改import tensorflow as tf

import tensorflow.compat.v1 as tf

tf.compat.v1.disable_eager_execution()

方法3:我采用上述兩種方式都不行,需要手動降TensorFlow的版本,方式為將高版本python改變成低版本python以安裝低版本tensorflow.

1、先卸載已有的TensorFlow,在終端中輸入:

pip uninstall tensorflow進行卸載

2、將編譯環(huán)境降為python3.6

由于python3.7以上安裝tensorflow只有2.x的版本,所以需要將編譯環(huán)境也降到python3.6

安裝python3.6,在終端中輸入:

conda create --name py36 python=3.6 anaconda

重啟pycharm,激活python3.6,在終端中輸入:

activate py36

驗證環(huán)境,在終端中輸入:

python –version

輸出為:

Python 3.6.13 :: Anaconda, Inc.

如果還是原來的版本,需要重新啟動下pycharm在檢查版本。

3、安裝低版本TensorFlow

安裝TensorFlow1.4.0,在終端中輸入:

pip install tensorflow==1.4.0 -i Simple Index

安裝成功

PS:新的編譯環(huán)境中可能會缺少很多需要用的包,需要采用pip install 下載相關包

4、后續(xù)問題補充

缺少cv2、sklearn… 在終端通過pip安裝

pip install opencv-python -i Simple Index

pip install scikit-learn -i https://pypi.douban.com/simple

繼續(xù)報錯:cannot import name ‘tf2‘

原因:keras的版本和tensorflow的版本不匹配,終端輸入:

pip list找到TensorFlow的版本

tensorflow???????????? 1.4.0

在對應表格中找到對應的keras版本,通過pip安裝

pip install keras==2.0.8 -i https://pypi.douban.com/simple

module 'tensorflow' has no attribute 'placeholder,opencv,python,卷積神經(jīng)網(wǎng)絡

每解決一個問題就運行下程序,遇到新的問題解決新的問題,直至程序能夠運行下去不報錯。

5、個人心得

如果網(wǎng)絡上提供的方法不能解決問題,不要一直找新的答案,要先清楚問題的原因是什么,再去解決。譬如本次報錯的主要問題主要是TensorFlow的版本不對,所以輸入什么代碼以及有沒有用不重要,重要的是需要尋找并完成TensorFlow低版本的替代工作。

如果我解決了你的問題,請點贊給我加油module 'tensorflow' has no attribute 'placeholder,opencv,python,卷積神經(jīng)網(wǎng)絡,也謝謝在解決問題過程中參考的諸位大佬們。。

?主要參考:

將高版本py與tensorflow改變成低版本python以安裝低版本tensorflow_樹頂上的橙子的博客-CSDN博客_安裝低版本tensorflow

?文章來源地址http://www.zghlxwxcb.cn/news/detail-812900.html

到了這里,關于手把手解決module ‘tensorflow‘ has no attribute ‘placeholder的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 【最簡單解決辦法】:module ‘tensorflow.compat.v1‘ has no attribute ‘contrib‘

    【最簡單解決辦法】:module ‘tensorflow.compat.v1‘ has no attribute ‘contrib‘

    目錄 出現(xiàn)錯誤界面 1.問題原因 2.解決辦法 (1)在調用之前首先添加如下代碼塊并執(zhí)行 (2)查找響應函數(shù)對應的函數(shù)調用前綴。 注:若出現(xiàn)錯誤也是LSTM預測,可直接復制如下代碼: 最后問題解決,代碼最后成功運行 anaconda下: tensorflow版本:tensorflow2.3.0 python版本:python3

    2023年04月25日
    瀏覽(16)
  • 解決AttributeError: module tensorflow has no attribute reset_default_graph

    目錄 解決AttributeError: module tensorflow has no attribute reset_default_graph 錯誤原因 解決方法 步驟1: 查看TensorFlow版本 步驟2: 替換過時的方法或屬性 步驟3: 更新代碼 步驟4: 手動重置默認圖(如果適用) 結論 在使用TensorFlow進行深度學習任務時,有時會遇到類似于\\\"AttributeError: module \\\'te

    2024年02月04日
    瀏覽(20)
  • 解決AttributeError: module ‘keras‘ has no attribute ……

    在成功解決AttributeError: module ‘keras‘ has no attribute ‘utils‘_new1998的博客-CSDN博客這篇博客中博主有提到如何解決這一問題,其中就是要把 更改成為 而博主不知道其中原因,原因其實是在TensorFlow 2.4及以上版本中, import keras 的方式已經(jīng)被棄用,取而代之的是 import tensorflow.k

    2024年02月11日
    瀏覽(31)
  • 解決AttributeError: module ‘serial‘ has no attribute ‘Serial‘

    最近在搞上位機時遇到了報錯AttributeError: module ‘serial’ has no attribute ‘Serial’,翻譯過來就是serial類沒有Serial對象。然后卡了一個小時才解決,試了網(wǎng)上很多方法,最后才發(fā)現(xiàn)報錯原因,這問題python也有責任。 下面說下一般的解決方法。 python3之后串口都改為pyserial,seria

    2024年02月02日
    瀏覽(19)
  • AttributeError: module ‘numpy‘ has no attribute ‘bool‘解決

    AttributeError: module ‘numpy‘ has no attribute ‘bool‘解決

    問題原因:在numpy的1.24版本已經(jīng)棄用了np.bool這個名稱,取而代之的是np.bool_ 解決方法: 1.點擊出錯文件 2.將np.bool更改為np.bool_

    2024年02月12日
    瀏覽(27)
  • 【已解決】AttributeError: module ‘numpy‘ has no attribute ‘int‘.

    【已解決】AttributeError: module ‘numpy‘ has no attribute ‘int‘.

    AttributeError: module ‘numpy’ has no attribute ‘int’. np.int was a deprecated alias for the builtin int . To avoid this error in existing code, use int by itself. Doing this will not modify any behavior and is safe. 新版本的numpy里面沒有np.int了。 第一種,降低numpy版本,安裝1.20以下的版本。 第二種,修改源碼。 將 修

    2024年02月14日
    瀏覽(26)
  • 【已解決】AttributeError: module ‘pandas‘ has no attribute ‘Series‘

    【已解決】AttributeError: module ‘pandas‘ has no attribute ‘Series‘

    問題描述:pandas是用于數(shù)據(jù)處理和分析的包,本文是基于筆者在進行模型訓練時遇到的一個問題,于是隨筆記錄下了從發(fā)現(xiàn)問題到解決問題的整個過程。 當遇到AttributeError: module \\\'pandas\\\' has no attribute \\\'Series\\\'這樣的錯誤,首先我是在python命令行中進行測試Series屬性是否可用。 ?

    2024年02月11日
    瀏覽(27)
  • 成功解決AttributeError: module ‘numpy‘ has no attribute ‘float‘.

    AttributeError: module ‘numpy’ has no attribute ‘float’. np.float was a deprecated alias for the builtin float . To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. The aliases was originally deprecated in NumPy 1.20; for

    2024年02月16日
    瀏覽(25)
  • AttributeError: module ‘numpy‘ has no attribute ‘a(chǎn)rray‘解決辦法

    AttributeError: module ‘numpy‘ has no attribute ‘a(chǎn)rray‘解決辦法

    NumPy是Python中重要的數(shù)值計算庫,提供了強大的數(shù)組操作和數(shù)學函數(shù)。然而,有時候我們可能會在使用NumPy時遇到\\\"AttributeError: module ‘numpy’ has no attribute ‘a(chǎn)rray’\\\"的錯誤提示,這可能會讓一些用戶感到困惑。在本文中,我們將分享如何解決這個問題的方法,并幫助讀者更好地

    2024年02月13日
    瀏覽(24)
  • Langchain module ‘hnswlib‘ has no attribute ‘Index‘ 錯誤解決

    使用 Langchain 操作 Chroma 向量數(shù)據(jù)庫時,報一下錯誤信息, 試著重裝了不同 hnswlib 版本沒有解決,最后解決方法是,不要使用 hnswlib,使用 chroma-hnswlib, 完結!

    2024年02月13日
    瀏覽(56)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包