其他分享
首页 > 其他分享> > Tensorflow出现Variable Actor/eval0/l1/kernel already exists, disallowed.

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中的默认图。

标签:kernel,eval0,name,exists,ops,Python,python,tensorflow,op
来源: https://www.cnblogs.com/zuiyixin/p/16079487.html