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

Keras Dense层输入未被展平

这是我的测试代码: from keras import…

无法将分类变量输入随机森林

我有10个分类变量和3个数值变量。我在分割后直接将它们…

如何在Keras中对每个输出应用Sigmoid函数?

这是我代码的一部分。 model = Sequenti…

如何选择类概率的最佳阈值?

我的神经网络输出是一个用于多标签分类的预测类概率表: …

在Keras中使用深度学习得到不同的结果

我按照一个教程使用Keras中的深度神经网络进行文本分…

‘MatMul’操作的输入’b’类型为float32,与参数’a’的类型float64不匹配

我写了一个简单的TensorFlow代码,但不断遇到T…

发表回复

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