Keras包的安装

我试图安装Keras包以使用机器学习工具,但不幸的是我无法成功。我已经安装了theano,并且在Python 3.5的独立环境中安装了tensorflow,但我这次想使用Python 2.7。这会是问题所在吗?

C:\Users\User>pip install tensorflow   Collecting tensorflow     Could not find a version that satisfies the requirement tensorflow (from versions: )   No matching distribution found for tensorflow   C:\Users\User>pip install kerasRequirement already satisfied: keras in c:\users\user\anaconda2\lib\site-packages   Requirement already satisfied: theano in c:\users\user\anaconda2\lib\site-packages (from keras)   Requirement already satisfied: pyyaml in c:\users\user\anaconda2\lib\site-packages (from keras)   Requirement already satisfied: six in c:\users\user\anaconda2\lib\site-packages (from keras)   Requirement already satisfied: numpy>=1.9.1 in c:\users\user\anaconda2\lib\site-packages (from theano->keras)   Requirement already satisfied: scipy>=0.14 in c:\users\user\anaconda2\lib\site-packages (from theano->keras)   

当我尝试导入Keras时,仍然遇到导入错误,提示没有找到tensorflow后端。


回答:

Tensorflow 官方仅在Windows上支持Python 3.5.x版本。对于Python 2,你需要将后端切换到Theano。你可以在C:\Users\username\.keras\keras.json中将Keras后端更改为Theano。另请查看文档。

如果你想在脚本中切换到另一个Keras后端,你也可以使用以下代码:

import osos.environ['KERAS_BACKEND'] = "theano" #or "tensorflow"import keras

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注