tensorflow中使用tf.variable_scope和tf.get_variable的ValueError

ValueError: Variable conv1/weights1 already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:

在使用tensorflow 中的tf.variable_scope和tf.get_variable搭建网络时,重复运行程序会报以上的ValueError错误,这是因为第二次运行时,内存中已经存在名字相同的层或者参数,发生了冲突,所以会提示是否要reuse。

解决方案:

(1)如果你用的是spyder编译的程序,重新启动一下python console就好了

(2)终端运行程序则不会出现上述问题

posted @ 2018-01-24 11:09  康小武  阅读(672)  评论(1编辑  收藏  举报