Keras 安装

虚拟机版本:VMWare 14

系统版本:Ubuntu Kilyn 14

 

前言:

  由于毕业论文的关系,需要用到深度学习。在知乎上看到了台湾李宏毅教授的Deep Learning Tutorial的ppt, 对深度学习进行了深入浅出的讲解,在文章提到了Keras框架,并使用它进行了Mnist手写数字识别——类地位上似于Deep Learning中“Hello World”的讲解。

 

简介:

  Keras是google深度学习研究员Francois Chollet 实现的TensorFlow和Theano的接口,易于学习和使用。可以在http://keras.io/上查看文档,示例程序在https://github.co/fchollet/keras/tree/master/examples上。

 

安装:

  一开始是打算直接在Windows上安装的,但是配置好之后显示错误。搜索后得知,似乎Windows上暂时不支持Theano,遂使用虚拟机安装Linux系统。

  参考博客的链接是:http://blog.csdn.net/u012556077/article/details/50364640 

  第一步,安装vim 和 git,这里使用命令:

     

sudo apt-get install vim git

  

  出现问题,未找到软件包。解决方案为:修改source.list文件(找不到原链接了)

  修改/etc/apt/sources.list,在末尾加上

 

 deb http:ftp.jp.debian.org/debian sid main

  deb http://dl.google.com/linux/deb/ stable non-free main

 

 

 

  第二步,安装Python及其包

  直接可以用Anaconda Python Distribution,然而其官网访问不了,开了VPN后仍然打不开。最后从https://mirrors.tuna.tsinghua.edu.cn/清华大学开源软件镜像站上下载了,上面东西还挺多的。得到的文件格式为Anaconda3-4.3.1-Linux-x86_64.sh

  

chmod +777 Anaconda3-4.3.1-Linux-x86_64.sh
./Anaconda3-4.3.1-Linux-x86_64.sh

  然后按照提示操作即可。

 

  第三步,安装Theano和TensorFlow

  先安装依赖包,要下载一段时间。

sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev 

  然后

sudo pip instal Theano

  第四步,安装GPU依赖包

  第五步,安装CuDNN(可选)

  我这两步都没装,参见http://blog.csdn.net/u012556077/article/details/50364640 

  第六步,Keras

  安装指令是:

cd

git clone https://github.com/fchollet/keras.git

cd keras

sudo python setup.py install

  或者

sudo pip install keras

  第七步,测试

  直接在shell中键入Python

 

  安装完成

后续:

  在跑addition_rnn.py时正常。

  在跑示例程序mnist_cnn.py时出现错误,NpzFile has no attribute zip.菜鸡的我只能知道是数据集读取出问题了,考虑不使用keras.mnist来读数据,暂未实现。

 

update:

推荐网站:http://keras-cn.readthedocs.io/

posted @ 2017-03-25 16:25  Run_dream  阅读(590)  评论(0编辑  收藏  举报