您的位置:首页 > 编程语言 > Python开发

keras包安装

2016-07-05 14:59 330 查看
Keras is a minimalist, highly modular neural networks library, written in Python and capable of running on top of either TensorFlow or Theano. It was developed with a focus on enabling fast experimentation. Being able to go from idea to result with the least possible delay is key to doing good research.

使用pip安装keras包,安装过程会自动下载安装theano。

>>> pip install keras


但是在导入keras运行代码的时候,出现如下警告:

WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.

http://www.cnblogs.com/anyview/p/5063189.html这篇博客中找到了解决办法:

>>> conda install mingw libpython


安装完成之后就可以了。

后面由于要使用NLTK中定义的stopwords,又出错了。

使用代码如下:

>>> from nltk.corpus import stopwords
>>> stop = stopwords.words('english')


报错信息如下:

LookupError:
********************************************
Resource 'corpora/stopwords' not found.  Please use the NLTK
Downloader to obtain the resource:  >>> nltk.download()
Searched in:
- 'C:\\Users\\Meru/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'C:\\Users\\Administrator\\Anaconda\\nltk_data'
- 'C:\\Users\\Administrator\\Anaconda\\lib\\nltk_data'
- 'C:\\Users\\Administrator\\AppData\\Roaming\\nltk_data'
********************************************


这是由于本地没有stopwords的语料库,所以在使用的时候就会报错,按照stackoverflow上的一个回答完美地解决了这个问题,网址是:

http://stackoverflow.com/questions/26693736/nltk-and-stopwords-fail-lookuperror

解决办法如下:

>>> import nltk
>>> nltk.download()


在Python console中输入上面两行代码之后会弹出一个如下所示的GUI:



可以自己选择需要下载的语料和下载到的位置。

也可以直接使用
nltk.download("stopwords")
下载停用词语料,默认的下载地址是’C:\Users\Administrator\AppData\Roaming\nltk_data…’

OK,这是今天干活的过程中遇到的几个小问题,记录一下~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python