在jupyter平台上使用keras和tensorflow之安装篇

使用平台为 win10,预先安装anaconda。使用包管理工具 conda和pip

0. 设置镜像源为中科大源

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

conda config --set show_channel_urls yes

1. 建立虚拟环境

conda create -n kr python=3.6

其中,kr为自定义虚拟环境的名称。

激活一个环境:

  • 在Windows上,在您的Anaconda提示符下运行 activate kr
  • 在macOS和Linux上,在终端窗口中运行 source activate kr

2. conda install nb_conda_kernels 

这条命令的目的是,在终端启动 jupyter时,可以选择python的运行在指定虚拟环境上完成。

3. 安装CPU版本的keres的后端 tensorFlow

pip install tensorflow==2.0 -i https://pypi.doubanio.com/simple

4. 安装CPU版本的keres

pip install keras==3.6.1 -i https://pypi.doubanio.com/simple

注意: 安装时注意keras和tensorflow的版本对应关系。比如 tensorflow version == 2.0 和 keras 3.6.1 匹配的具体的对应关系可以见网页:

https://docs.floydhub.com/guides/environments/

原文地址:https://www.cnblogs.com/cofludy/p/13288905.html