Keras安装

人工智能66

keras安装

文章目录

*
- keras安装
* 前言
* 一、安装Keras前提
*
- 1.安装Anaconda
- 2.安装tensorflow
- 如果像我一样点背,出现了如下问题
* 二、Keras安装步骤
* 总结

前言

本次安装基于Python

一、安装Keras前提

1.安装Anaconda

直接从网址https://www.anaconda.com/products/individual#download-section点击Download,选择对应版本下载。安装过程一路next,在Select Installation Type 中两个都勾选,如图1
Keras安装

图1
然后点击install就安装好了。接着验证是否安装成功,win+R输入cmd,打开命令窗口,输入 conda --version,出现版本表示安装成功,如图2。
Keras安装图2

; 2.安装tensorflow

先打开我们刚安装好的Anaconda中的 Anaconda Prompt(开始->Anaconda->Anaconda Prompt),如图3:
Keras安装图3
然后输入:(复制过去就好了)

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

再接着输入:

conda config --set show_channel_urls yes

安装Tensorflow时,需要从Anaconda仓库中下载,一般默认链接的都是国外镜像地址,要变成国内的需要改一下链接镜像的地址(跨国比较慢)。上述两行代码是用来改镜像代码的。

接下来安装Tensorflow,在Anaconda Prompt中输入:

conda create -n tensorflow python=3.5.2

出现图4
Keras安装图4
输入y,顺利的话就完成了tensorflow的安装。如果自己已有tensorflow请跳过上述步骤

如果像我一样点背,出现了如下问题

Keras安装图5
开始解决(我也是上网查的)
首先切换镜像

conda config --add channels https://mirrors.ustc.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/pkgs/free/
conda config --set show_channel_urls yes

这四条依次输进去,然后找到c盘user文件里的.condarc,把里面的https 修改为 http
,删除 defaul那行,改后的文件如下
Keras安装图6
回来运行一下

Keras安装图7
我还是错了,我气死...

然后,然后我以管理员的身份进入 Anaconda Prompt,再重新按装,命令行同上为conda create -n tensorflow python=3.5.2,继续y,居然成功了,啊这...就这啊...我刚才干嘛呢

Keras安装图8
下载tensorflow
pip install tensorflow,然后我就莫名其妙满江红了,不着急看一下问题在哪
Keras安装图9
版本有点问题,先 pip --version一下,然后

python -m pip install --upgrade pip

就是这了,成功!!!

激活下吧,输入activate tensorflow,OK这一进程结束。

二、Keras安装步骤

还是管理员身份,在Anaconda prompt,依次输入

conda install mingw libpython

继续输入y,等他装好。

pip install theano

一样等着装好就行了

pip install keras

一样一样

然后我到这又又又满江红了???他又出错了
Keras安装图10
再输入pip --default-timeout=1000 install keras尝试一下,没有报错。

测试Keras安装是否成功:
输入python,再输入import keras,如果没有报错,恭喜你安装成功了!!!!!!!!!

总结

也没啥总结的,本人菜鸡一只,欢迎各位大佬批评指正!!!

Original: https://blog.csdn.net/weixin_45822156/article/details/115732039
Author: weixin_45822156
Title: Keras安装