Variable conv1/weights already exists, disallowed. Did you mean to set reuse=Tru

weixin_40736039 2017-10-23 11:04:34
ValueError                                Traceback (most recent call last)
<ipython-input-13-8ae8e5b3e751> in <module>()
23 BATCH_SIZE,
24 CAPACITY)
---> 25 train_logits = model.inference(train_batch, BATCH_SIZE, N_CLASSES)
26 train_loss = model.losses(train_logits, train_label_batch)
27 train_op = model.trainning(train_loss, learning_rate)

E:\cat and dog\model.py in inference(images, batch_size, n_classes)
8 shape=[3, 3, 3, 16],
9 dtype=tf.float32,
---> 10 initializer=tf.truncated_normal_initializer(stddev=0.1, dtype=tf.float32))
11 biases = tf.get_variable('biases',
12 shape=[16],

D:\Anaconda\lib\site-packages\tensorflow\python\ops\variable_scope.py in get_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
1022 collections=collections, caching_device=caching_device,
1023 partitioner=partitioner, validate_shape=validate_shape,
-> 1024 custom_getter=custom_getter)
1025
1026

D:\Anaconda\lib\site-packages\tensorflow\python\ops\variable_scope.py in get_variable(self, var_store, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
848 collections=collections, caching_device=caching_device,
849 partitioner=partitioner, validate_shape=validate_shape,
--> 850 custom_getter=custom_getter)
851
852 def _get_partitioned_variable(self,

D:\Anaconda\lib\site-packages\tensorflow\python\ops\variable_scope.py in get_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
344 reuse=reuse, trainable=trainable, collections=collections,
345 caching_device=caching_device, partitioner=partitioner,
--> 346 validate_shape=validate_shape)
347
348 def _get_partitioned_variable(

D:\Anaconda\lib\site-packages\tensorflow\python\ops\variable_scope.py in _true_getter(name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape)
329 initializer=initializer, regularizer=regularizer, reuse=reuse,
330 trainable=trainable, collections=collections,
--> 331 caching_device=caching_device, validate_shape=validate_shape)
332
333 if custom_getter is not None:

D:\Anaconda\lib\site-packages\tensorflow\python\ops\variable_scope.py in _get_single_variable(self, name, shape, dtype, initializer, regularizer, partition_info, reuse, trainable, collections, caching_device, validate_shape)
630 " Did you mean to set reuse=True in VarScope? "
631 "Originally defined at:\n\n%s" % (
--> 632 name, "".join(traceback.format_list(tb))))
633 found_var = self._vars[name]
634 if not shape.is_compatible_with(found_var.get_shape()):

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

File "D:\Anaconda\lib\site-packages\tensorflow\python\framework\ops.py", line 1128, in __init__
self._traceback = _extract_stack()
File "D:\Anaconda\lib\site-packages\tensorflow\python\framework\ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
File "D:\Anaconda\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 759, in apply_op
op_def=op_def)


训练猫狗大战训练集的时候遇到了上述问题,看不懂,求大神指教
...全文
9834 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChenEthan_ 2020-11-02
  • 打赏
  • 举报
回复
解决了吗?还是报错
weixin_44119674 2020-06-12
  • 打赏
  • 举报
回复
不行啊,還是報錯。ValueError: Variable degridding/conv1/weights already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at
Jia10143 2019-04-05
  • 打赏
  • 举报
回复
"model.inference" 代指你构建神经网络模型的 那块脚本
qq_41544846 2018-11-14
  • 打赏
  • 举报
回复
您好,我想请问一下 model.inference(train_batch, BATCH_SIZE, N_CLASSES) 这个在哪里啊,菜鸟不会找。。。。 哭晕过去了
Bigcat_u 2018-08-23
  • 打赏
  • 举报
回复
方法很好,完美解决问题,亲测
liujiaoatcd 2018-03-29
  • 打赏
  • 举报
回复
model.inference(train_batch, BATCH_SIZE, N_CLASSES)这个里面应该有with tf.variable_scope('layer1'):这样的代码,改为with tf.variable_scope('layer1', reuse = tf.AUTO_REUSE):
Monster_Zhong 2018-01-23
  • 打赏
  • 举报
回复
在最前面加上这句代码:tf.reset_default_graph()
studyzen 2017-11-06
  • 打赏
  • 举报
回复
model.inference(train_batch, BATCH_SIZE, N_CLASSES)这个里面应该有with tf.variable_scope('layer1'):这样的代码,改为with tf.variable_scope('layer1', reuse = reuse):第二个参数传True

4,446

社区成员

发帖
与我相关
我的任务
社区描述
图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧