TensorFlow教程

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

这篇关于Tensorflow出现Variable Actor/eval0/l1/kernel already exists, disallowed.的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!