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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

keras环境搭建 [过程记录]

發布時間:2023/12/19 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 keras环境搭建 [过程记录] 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1 虛擬環境安裝

1.安裝anaconda

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

2.進入anaconda prompt

conda config --show channels conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ #如果想刪掉 conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ #但是上面那種方法會把channels變成空的[],所以我們還是選擇換回默認源更好 conda config --remove-key channels #查看當前使用源 conda config --show-sources #ssl_verify: True #show_channel_urls: True conda create -n keras #創建虛擬環境 conda activate keras #進入虛擬環境 pip install tensorflow==2.0 -i https://pypi.doubanio.com/simple pip install keras-i https://pypi.doubanio.com/simple #報錯Cannot unpack file后改為下面一行可正常運行 pip install keras -i https://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com python #進入python #測試是否安裝成功 #導入keras時使用如下代碼,在 tensorflow2.X 中導入keras模塊代碼使用下述方法會報錯 from keras.layers import Input, Dense, Conv2D, MaxPooling2D, PReLU, Flatten, Softmax from keras.models import Model#解決辦法:將上述py文件中代碼修改為: from tensorflow.keras.layers import Input, Dense, Conv2D, MaxPooling2D, PReLU, Flatten, Softmax from tensorflow.keras.models import Model#ImportError: cannot import name ‘get_config’ from ‘tensorflow.python.eager.context’ 這個類型報錯的問題我遇到的都可以通過導入包時使用tensorflow.keras解決#該報錯解決方案的原文鏈接:https://blog.csdn.net/qq_29304033/article/details/117258910 conda install nb_conda #這一句一直報錯,感覺是和之前conda鏡像怎么都設置不好有關 #暫未解決,但不知道為什么jupyter notebook不進入虛擬環境也莫名可以使用tensorflow.keras #xs 不知道為什么根本就沒裝到虛擬環境里去,直接裝在base環境里了,把虛擬環境文件夾刪了…就先這樣吧

所以整理一個不在虛擬環境里搭建keras的方法:

2 直接安裝

1.下載anaconda

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

2.進入anaconda prompt

#安裝后端tensorflow pip install tensorflow==2.0 -i https://pypi.doubanio.com/simple#安裝前端keras pip install keras -i https://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com python #進入python #測試是否安裝成功 #導入keras時使用如下代碼,在 tensorflow2.X 中導入keras模塊代碼使用下述方法會報錯 from keras.layers import Input, Dense, Conv2D, MaxPooling2D, PReLU, Flatten, Softmax from keras.models import Model#解決辦法:將上述py文件中代碼修改為: from tensorflow.keras.layers import Input, Dense, Conv2D, MaxPooling2D, PReLU, Flatten, Softmax from tensorflow.keras.models import Model#ImportError: cannot import name ‘get_config’ from ‘tensorflow.python.eager.context’ 這個類型報錯的問題我遇到的都可以通過導入包時使用tensorflow.keras解決#該報錯解決方案的原文鏈接:https://blog.csdn.net/qq_29304033/article/details/117258910 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的keras环境搭建 [过程记录]的全部內容,希望文章能夠幫你解決所遇到的問題。

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