Tensorflow出现Variable Actor/eval0/l1/kernel already exists, disallowed.
2022/3/30 23:19:31
本文主要是介绍Tensorflow出现Variable Actor/eval0/l1/kernel already exists, disallowed.,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
参考链接:
https://blog.csdn.net/weixin_43283397/article/details/103289928?spm=1001.2014.3001.5506
1.问题描述
Spyder或者Jupyter中重复运行Tensorflow的代码,会出现变量已经存在的问题。这是因为这些编辑器都会自动保存变量。
具体错误描述:
ValueError: Variable Actor/eval0/l1/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at: File "C:\Users\23820\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\ops.py", line 1990, in __init__ self._traceback = tf_stack.extract_stack() File "C:\Users\23820\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\ops.py", line 3536, in _create_op_internal op_def=op_def) File "C:\Users\23820\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\op_def_library.py", line 750, in _apply_op_helper attrs=attr_protos, op_def=op_def) File "C:\Users\23820\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\gen_state_ops.py", line 1752, in variable_v2 shared_name=shared_name, name=name) File "C:\Users\23820\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\state_ops.py", line 79, in variable_op_v2 shared_name=shared_name)
2.解决方案
2.1.直接删除变量,再运行或者重新打开Python的kernel刷新变量。
2.2.在代码中加入tf.reset_default_graph()
来清理tensorflow中的默认图。
这篇关于Tensorflow出现Variable Actor/eval0/l1/kernel already exists, disallowed.的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-30tensorflow是什么-icode9专业技术文章分享
- 2024-10-15成功地使用本地的 NVIDIA GPU 运行 PyTorch 或 TensorFlow
- 2024-01-23供应链投毒预警 | 恶意Py包仿冒tensorflow AI框架实施后门投毒攻击
- 2024-01-19attributeerror: module 'tensorflow' has no attribute 'placeholder'
- 2024-01-19module 'tensorflow.compat.v2' has no attribute 'internal'
- 2023-07-17【2023年】第33天 Neural Networks and Deep Learning with TensorFlow
- 2023-07-10【2023年】第32天 Boosted Trees with TensorFlow 2.0(随机森林)
- 2023-07-09【2023年】第31天 Logistic Regression with TensorFlow 2.0(用TensorFlow进行逻辑回归)
- 2023-07-01【2023年】第30天 Supervised Learning with TensorFlow 2(用TensorFlow进行监督学习 2)
- 2023-06-18【2023年】第29天 Supervised Learning with TensorFlow 1(用TensorFlow进行监督学习 1)