Variable W already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at
解决方案:
加入:tf.reset_default_graph()
我的情况是:模型代码在文档里面,用Notebook进行加载,发现重复运行两次相同的代码就会出现上述错误。
一开始我的模型源码不同的位置加入均无法正常通过,报各种错误;
最后在Notebook里面需要运行的block中加入
tf.reset_default_graph()
import tensorflow as tf
tf.reset_default_graph()
json_pritimive = "******.custom.nlp.Textcnn"
obj = AIPrimitive()
obj.load_from_json(json_pritimive)
obj.fit(X=X_tokenized,y=y_train)
X_predict = obj.produce(X=X_tokenized)
就运行正常了