我安装了Keras。当我导入Keras时,它提示TensorFlow未安装。我尝试在keras.json文件中将后端更改为Theano,但这并没有帮助,因为它仍然提示没有名为TensorFlow的模块。请帮助我解决这个问题。
回答:
你试过这个吗?
你会在以下位置找到Keras配置文件:
$HOME/.keras/keras.json
默认的配置文件看起来像这样:
{"image_data_format": "channels_last","epsilon": 1e-07,"floatx": "float32","backend": "tensorflow"}
只需将backend
字段更改为"theano"
、"tensorflow"
或"cntk"
,Keras在你下次运行任何Keras代码时就会使用新的配置。
你还可以定义环境变量KERAS_BACKEND,这将覆盖配置文件中定义的内容:
KERAS_BACKEND=tensorflow python -c "from keras import backend"