如何使用 Keras 切换后端(从 TensorFlow 到 Theano) [英] How to switch Backend with Keras (from TensorFlow to Theano)

查看:43
本文介绍了如何使用 Keras 切换后端(从 TensorFlow 到 Theano)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 Keras 切换后端(从 TensorFlow 到 Theano),但没有成功.我按照此处描述的临时文件进行操作,但它不起作用.我在 keras 的目录中创建了一个 keras.json(因为它不存在)但是当我从 Python 导入它时它没有改变任何东西.

I tried to switch Backend with Keras (from TensorFlow to Theano) but did not manage. I followed the temps described here but it doesn't work. I created a keras.json in the keras' directory (as it did not exist) but it doesn't change anything when I import it from Python.

推荐答案

在您的主目录中创建一个 .keras(注意前面的 .)文件夹并将keras.json 文件在那里.

Create a .keras (note the . in front) folder in you home directory and put the keras.json file there.

例如,/home/DaniPaniz/.keras/keras.json(或简称为 ~/.keras/keras.json),如果您使用的是 UNIX像系统(MacOS X、Linux、*BSD).在 Windows 上,您要创建文件夹 %USERPROFILE%/.keras 并将 JSON 文件放在那里.

For example, /home/DaniPaniz/.keras/keras.json (or ~/.keras/keras.json in short) if you are on a UNIX like system (MacOS X, Linux, *BSD). On Windows you want to create the folder %USERPROFILE%/.keras and put the JSON file there.

或者,您也可以设置环境变量KERAS_BACKEND:

Alternatively, you can also set the environment variable KERAS_BACKEND:

KERAS_BACKEND=theano python mymodel.py

这篇关于如何使用 Keras 切换后端(从 TensorFlow 到 Theano)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆