gpt4 book ai didi

python - Keras 包安装

转载 作者:行者123 更新时间:2023-11-30 09:19:35 25 4
gpt4 key购买 nike

我正在尝试安装 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 keras
Requirement 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 officially仅支持 Windows 上的 Python 3.5.x。对于 python 2,您需要将后端切换到 Theano。您可以在 C:\Users\username\.keras\keras.json 中将 Keras 后端更改为 Theano。另请检查this文档。

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

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

关于python - Keras 包安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45016311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com