如何将Keras的后端更改为Theano? [英] How to change the backend of Keras to Theano?
问题描述
我安装了keras.当我导入keras时,它说未安装tensorflow.我尝试将keras.json文件中的后端更改为theano.但这无济于事,因为它仍然说没有名为tensorflow的模块.请帮我解决这个问题.
I installed keras. When I import keras, it says tensorflow not installed. I tried changing the backend in keras.json file to theano. But this doesn't help as it still says no module named tensorflow. Please help me fix this.
推荐答案
you will find the Keras configuration file at:
$HOME/.keras/keras.json
默认配置文件如下:
{
"image_data_format": "channels_last",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}
只需将字段backend
更改为"theano"
,"tensorflow"
或"cntk"
,当您下次运行任何Keras代码时,Keras将使用新配置.
Simply change the field backend
to "theano"
, "tensorflow"
, or "cntk"
, and Keras will use the new configuration next time you run any Keras code.
您还可以定义环境变量KERAS_BACKEND,它将覆盖配置文件中定义的内容:
You can also define the environment variable KERAS_BACKEND and this will override what is defined in your config file :
KERAS_BACKEND=tensorflow python -c "from keras import backend"
这篇关于如何将Keras的后端更改为Theano?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!