...weights already exists, disallowed. Did you mean to set reuse=True...(解决办法)

    xiaoxiao2025-06-21  13

    出错原因是TensorFlow的变量名被重新定义了。

    解决:

    1 若想要继续使用并共享当前的TensorFlow模型结构或变量:

    按照报错的提示信息加上reuse=True,例如:

    with tf.variable_scope("a",reuse=True): b = tf.get_variable("b",[0])

    2 若想要继续使用但不共享当前的TensorFlow模型结构或变量:

    修改变量名,使其和默认的变量不重名。

    3 若想丢弃当前TensorFlow的图,重新开始构图:

    在报错位置前加上一行:

    tf.reset_default_graph() # 清除默认图像的堆栈,并重置默认图
    最新回复(0)