keras后端theano/tensorflow

问题描述:

我在使用keras后端时遇到问题.我将tensorflow设置为后端.我检查./keras/keras.json、activate.d和activate.sh以将tensorflow作为后端.我还试图将envs变量强制为tensorflow.
第一次在jupyter上运行keras,它工作正常.我也可以导入tensorflow而没有任何错误.

I have an issue using keras backend. I set up tensorflow as the backend. I check the ./keras/keras.json, the activate.d and activate.sh to have tensorflow as backend. I also tried to force the envs variable to tensorflow.
The first time a run keras on the jupyter, it works fine. I can also import tensorflow without any bugs.

但是,当我现在使用jupyter笔记本时,后端是theano.

However when I use jupyter notebook now, the backend is theano.

我尝试在ipython上导入keras,后端是tensorflow.

I try to import keras on ipython and the backend is tensorflow.

我用conda安装keras,tensorflow和theano.

I install keras, tensorflow and theano with conda.

python版本:3.6

python version : 3.6

keras:2.0.6

keras : 2.0.6

tensorflow:1.3.0

tensorflow : 1.3.0

theano:0.9

theano : 0.9

操作系统:win10

OS : win10

我尝试了多种方法将jupyter笔记本的后端更改为tensorflow,但似乎不起作用.

I try different ways to change the backend to tensorflow for jupyter notebook but it does not seem to work.

通常,使用conda,我们创建(理论上)彼此独立的特定环境.

Usually, with conda, we create specific environments that are (theoretically) independent from the others.

我建议您使用conda创建一个Tensorflow环境.使用命令提示符:

I suggest you create a tensorflow environment using conda. Using the command prompt:

conda create -n myTensorflowEnv python=3.5

然后激活此环境:

activate myTensorflowEnv

然后,环境名称应出现在命令提示符开头的括号之间. (以防万一,您可能需要设置一些变量:如何激活Anaconda环境)

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)

在此环境中,您将安装所需的一切:Tensorflow,Keras和其他依赖项.但是,此过程将取决于您想要的是cpu,gpu,编译等.

Inside this environment, you install everything you need: Tensorflow, keras and other dependencies. This process will depend on what you want, though, cpu, gpu, compilations, etc.

您可能也应该在此环境中安装jupyter. (也许-仅当您遇到我在评论中提到的可怕错误时-才先卸载其他jupyters).

You should probably install jupyter in this environment as well. (And perhaps -- only if you have the terrible bug I mentioned in my comment -- uninstall the other jupyters first).

如果一切顺利,那么如果在此环境中运行jupyter,则可以在此环境中使用tensorflow.

If everything goes well, you will be able to use tensorflow in this environment if you run jupyter from this environment.