有没有办法切换tensorflow的版本?,当我使用conda安装tensorflow 2.0时,它更新了很多东西,甚至是python。跑步时conda list
它显示两个版本;
张量流2.0.0 mkl_py37h66b46cc_0
张量流 1.13.1
为了使用 1.x 版本,建议here http://www.google.com/取代import tensorflow as tf
对于以下内容:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
使用此方法是安全的,只需添加这些行?,在我的情况下,它显示一个警告:
WARNING:tensorflow:From /home/common/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/compat/v2_compat.py:65: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
我个人会在这里使用两个不同的虚拟环境。这将确保您在使用 2.0 与 1.x 时不会出现依赖性问题。 Conda 环境非常易于使用。例如:
创造环境
conda create --tensorflow1
激活环境
conda activate tensorflow1
激活环境后,您可以 conda/pip 安装 TensorFlow 1.x,所有依赖项都将包含在环境中。您可以使用 TensorFlow 2.0 做同样的事情。
我无法评论您发布的上述解决方案,但在这些情况下虚拟环境非常有用。
完整文档在这里:
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)