Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally  defined at:

在使用Inception V3等预训练模型,训练新的模型的时候,出现以下错误

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

 

原因:原因是我要做十交叉验证,所以每次都要加载预训练的模型,但是之所以报这样的错,是因为再进入第二折实验时,之前的模型session graph没有清楚,导致之前的变量什么的还存在。所以应该每折训练的时候清空graph。

在调用模型之前加入tf.reset_default_graph()这句就可以了

参考链接

https://github.com/kratzert/finetune_alexnet_with_tensorflow/issues/8

I don't get this error with neither of the two TensorFlow versions. Note that code block 3 should only be executed once! If you want to execute the block of the graph creation again, TensorFlow will raise this error, because the graph (with it's layer names) already exists. If you run this notebook block after block there should be absolutely no problem.
In the case you want to re-run codeblock 3 (for what ever reason) just insert a simple tf.reset_default_graph() at the beginning of the block. This will reset the graph you have already create and though you can create it again.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值