【发布时间】:2017-12-19 21:07:22
【问题描述】:
我目前使用 tensorflow 作为后端来处理 keras。我最近使用 python 3.5.3 和 tensorflow-gpu 1.4.0 创建了一个 conda 环境来试验 keras 2.0.9 的多 GPU 设施。在那个新环境中,keras 始终使用 Theano 作为后端。
我检查了~/.keras/keras.json,后端设置为tensorflow。但是,当我 source activate 进入这个新环境时,我看到 KERAS_BACKEND 环境变量设置为 theano。将其设置回tensorflow 有效。但是,我不明白theano的这种自动设置。我已经创建了更多的环境,并且默认都使用 tensorflow,因为我从来没有安装过 theano,也没有安装在这个新创建的环境中。 2.0.9 有什么变化吗?我在 anaconda 目录中找不到任何 keras.json。
有谁知道在向新环境采购时如何防止变量 KERAS_BACKEND 到 theano?
编辑
@Yu Yang 指出有类似问题的用户。答案是重新安装或更改文件activate.sh。我做了最后一个(见下文)但仍然 theao 返回为KERAS_BACKEND。
$ cat bin/anaconda3/pkgs/keras-2.0.9-py35_0/info/recipe/activate.sh
#!/bin/bash
if [ "$(uname)" == "Darwin" ]
then
# for Mac OSX
export KERAS_BACKEND=tensorflow
elif [ "$(uname)" == "Linux" ]
then
# for Linux
# export KERAS_BACKEND=theano
export KERAS_BACKEND=tensorflow
fi
【问题讨论】:
-
虽然在不同的 Keras 版本下,您的问题看起来与this one 非常相似。 conda keras包有问题,好像还没解决。
-
谢谢。我尝试了更改 activate.sh 的建议(请参阅编辑)。那没有用。我会看看是否可以选择重新安装。
标签: python-3.x tensorflow keras anaconda theano