在搭建网络的时候,出现类似这样的错误,说变量Variable word_encoded已经存在,这个word encoder是我的name scope中的一个。
问题出在这样,我重复使用了这个命名,我有个函数是这样的:
def A(inputx):
name_scope('word_encoder')
.....
我在网络中分别使用这个函数处理了两个数据
A(inputx1)
A(inputx2)
这个就出现标题 中的错误了......
如果解决中,就是在调用函数的时候传入不同的命名参数,我把这个函数改成了
def A(inputx,name):
name_scope('word_encoder'+name)
.....
这样我调用函数的时候
A(inputx1,"input1")
A(inputx2,"input2")
这样就会有不同的name scope了,这样问题就解决了