我想在tf.contrib模块中使用初始化器和批量归一化,但我的程序提示找不到这些功能。我重新安装了TensorFlow,但仍然无法使用tf.contrib模块。谁能告诉我这是为什么?
回答:
我不知道你做了什么,但你显然没有安装最新的Google TensorFlow版本。你应该按照这个教程来安装它。
总结如下:
- 确保你已安装所需依赖:
sudo apt-get install python-pip python-dev
- 卸载当前已安装的版本:
pip uninstall tensorflow
- 设置变量:
选择正确的选项:
# Ubuntu/Linux 64位,仅CPU,Python 2.7$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl# Ubuntu/Linux 64位,支持GPU,Python 2.7 # 需要CUDA工具包7.5和CuDNN v4。其他版本请参见下面的“从源代码安装”。$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl# Ubuntu/Linux 64位,仅CPU,Python 3.4$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp34-cp34m-linux_x86_64.whl# Ubuntu/Linux 64位,支持GPU,Python 3.4 # 需要CUDA工具包7.5和CuDNN v4。其他版本请参见下面的“从源代码安装”。$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp34-cp34m-linux_x86_64.whl# Ubuntu/Linux 64位,仅CPU,Python 3.5$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl# Ubuntu/Linux 64位,支持GPU,Python 3.5 # 需要CUDA工具包7.5和CuDNN v4。其他版本请参见下面的“从源代码安装”。$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl
- 安装它
选择正确的选项:
# Python 2$ sudo pip install --upgrade $TF_BINARY_URL# Python 3$ sudo pip3 install --upgrade $TF_BINARY_URL