简体   繁体   English

keras后端theano / tensorflow

[英]keras backend theano/tensorflow

I have an issue using keras backend. 我在使用keras后端时遇到问题。 I set up tensorflow as the backend. 我将tensorflow设置为后端。 I check the ./keras/keras.json, the activate.d and activate.sh to have tensorflow as backend. 我检查./keras/keras.json、activate.d和activate.sh以将tensorflow作为后端。 I also tried to force the envs variable to tensorflow. 我还试图将envs变量强制为tensorflow。
The first time a run keras on the jupyter, it works fine. 第一次在jupyter上运行keras,效果很好。 I can also import tensorflow without any bugs. 我也可以导入tensorflow而没有任何错误。

However when I use jupyter notebook now, the backend is theano. 但是,当我现在使用jupyter笔记本时,后端是theano。

I try to import keras on ipython and the backend is tensorflow. 我尝试在ipython上导入keras,后端是tensorflow。

I install keras, tensorflow and theano with conda. 我用conda安装keras,tensorflow和theano。

python version : 3.6 python版本:3.6

keras : 2.0.6 keras:2.0.6

tensorflow : 1.3.0 张量流:1.3.0

theano : 0.9 茶野:0.9

OS : win10 操作系统:Win10

I try different ways to change the backend to tensorflow for jupyter notebook but it does not seem to work. 我尝试了多种方法将jupyter Notebook的后端更改为tensorflow,但似乎不起作用。

Usually, with conda, we create specific environments that are (theoretically) independent from the others. 通常,使用conda,我们会创建特定的环境(理论上)与其他环境独立。

I suggest you create a tensorflow environment using conda. 我建议您使用conda创建一个tensorflow环境。 Using the command prompt: 使用命令提示符:

conda create -n myTensorflowEnv python=3.5

And then you activate this environment: 然后激活此环境:

activate myTensorflowEnv

The name of your environment should then appear in between parentheses at the beginning of the command prompt. 然后,环境名称应出现在命令提示符开头的括号之间。 (In case this doesn't work, you may need to setup some vars: How to activate an Anaconda environment ) (以防万一这不起作用,您可能需要设置一些变量: 如何激活Anaconda环境

Inside this environment, you install everything you need: Tensorflow, keras and other dependencies. 在此环境中,您将安装所需的一切:Tensorflow,Keras和其他依赖项。 This process will depend on what you want, though, cpu, gpu, compilations, etc. 但是,此过程取决于您想要的是cpu,gpu,编译等。

You should probably install jupyter in this environment as well. 您可能也应该在此环境中安装jupyter。 (And perhaps -- only if you have the terrible bug I mentioned in my comment -- uninstall the other jupyters first). (也许-仅当您遇到我在评论中提到的可怕错误时-才先卸载其他jupyters)。

If everything goes well, you will be able to use tensorflow in this environment if you run jupyter from this environment. 如果一切顺利,那么如果您在此环境中运行jupyter,则可以在该环境中使用tensorflow。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM