您当前的位置:首页 > IT编程 > Keras
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 |

自学教程:keras2环境安装详细记录

51自学网 2023-09-14 13:08:12
  Keras
这篇教程keras2环境安装详细记录写得很实用,希望能帮到您。
在tf2之后,不再分cpu和GPU版本,安装tf2之后也不必安装keras,keras已经封装在tf2.

ubuntu22.4    anaconda 3  下开始创建:
创建名为py374的虚拟环境:conda create -n py374 python=3.7
切到py374:conda activate py374
查看可用的cudatoolkit:  conda search cudatoolkit

(py374) zjy@zjy-System-Product-Name:~/tang/17flowers$ conda search cudatoolkit
Loading channels: done
# Name                       Version           Build  Channel             
cudatoolkit                      9.0      h13b8566_0  pkgs/main           
cudatoolkit                      9.2               0  pkgs/main           
cudatoolkit                 10.0.130               0  pkgs/main           
cudatoolkit                 10.1.168               0  pkgs/main           
cudatoolkit                 10.1.243      h6bb024c_0  pkgs/main           
cudatoolkit                  10.2.89      hfd86e86_0  pkgs/main           
cudatoolkit                  10.2.89      hfd86e86_1  pkgs/main           
cudatoolkit                 11.0.221      h6bb024c_0  pkgs/main           
cudatoolkit                   11.3.1      h2bc3f7f_2  pkgs/main           
cudatoolkit                   11.8.0      h6a678d5_0  pkgs/main 

根据自己的tf版本需求选择对应的版本安装
这里选择安装tf2.1,对应的keras为2.3.1,cuda10.1,cudnn7.6

conda install cudatoolkit==10.1.243 
(py374) zjy@zjy-System-Product-Name:~/tang/17flowers$ conda search cudnn
Loading channels: done
# Name                       Version           Build  Channel             
cudnn                          7.0.5       cuda8.0_0  pkgs/main           
cudnn                          7.1.2       cuda9.0_0  pkgs/main           
cudnn                          7.1.3       cuda8.0_0  pkgs/main           
cudnn                          7.2.1       cuda9.2_0  pkgs/main           
cudnn                          7.3.1      cuda10.0_0  pkgs/main           
cudnn                          7.3.1       cuda9.0_0  pkgs/main           
cudnn                          7.3.1       cuda9.2_0  pkgs/main           
cudnn                          7.6.0      cuda10.0_0  pkgs/main           
cudnn                          7.6.0      cuda10.1_0  pkgs/main           
cudnn                          7.6.0       cuda9.0_0  pkgs/main           
cudnn                          7.6.0       cuda9.2_0  pkgs/main           
cudnn                          7.6.4      cuda10.0_0  pkgs/main           
cudnn                          7.6.4      cuda10.1_0  pkgs/main           
cudnn                          7.6.4       cuda9.0_0  pkgs/main           
cudnn                          7.6.4       cuda9.2_0  pkgs/main           
cudnn                          7.6.5      cuda10.0_0  pkgs/main           
cudnn                          7.6.5      cuda10.1_0  pkgs/main           
cudnn                          7.6.5      cuda10.2_0  pkgs/main           
cudnn                          7.6.5       cuda9.0_0  pkgs/main           
cudnn                          7.6.5       cuda9.2_0  pkgs/main           
cudnn                          8.2.1      cuda11.3_0  pkgs/main           
cudnn                       8.9.2.26        cuda11_0  pkgs/main       
conda install cudnn==7.6.5


pip install tensorflow==2.1.0

pip install keras==2.3.1 (不装也可以用)

运行后,出现如下错误:
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

升级一下protobuf
(py374) zjy@zjy-System-Product-Name:~/tang/17flowers$ pip install protobuf==3.20.0

ModuleNotFoundError: No module named 'sklearn'
(py374) zjy@zjy-System-Product-Name:~/tang/17flowers$ pip install sklearn
Collecting sklearn
  Downloading sklearn-0.0.post9.tar.gz (3.6 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
 
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      The 'sklearn' PyPI package is deprecated, use 'scikit-learn'



(py374) zjy@zjy-System-Product-Name:~/tang/17flowers$ pip install scikit-learn


ModuleNotFoundError: No module named 'imutils'
解决:pip install imutils


ModuleNotFoundError: No module named 'matplotlib'
pip install matplotlib

返回列表
Keras实现注意力机制(self-attention)中文的文本情感分类(详细注释)
51自学网自学EXCEL、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。
京ICP备13026421号-1