Tensorflow-gpu 训练 cifar10 遇到问题

本文解决了TensorFlow中使用多GPU训练模型时遇到的变量不存在问题,并提供了详细的代码修改方案。此外,还推荐了一个包含多个经典案例的GitHub仓库,帮助读者更好地理解和应用多GPU训练。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. tensorflow 新老版本的问题,常见的问题下面的这篇博文已经列出

http://blog.youkuaiyun.com/zeuseign/article/details/72771598

2. Tensorflow cifar10_multi_gpu问题:Variable conv1/weights/ExponentialMovingAverage/ does not exist...

这个问题的解决方案是在 for i in xrange(FLAGS.num_gpus): 的外面加上with tf.variable_scope(tf.get_variable_scope()):

with tf.variable_scope(tf.get_variable_scope()):
    for i in xrange(FLAGS.num_gpus):
        with tf.device('/gpu:%d' % i):

原因:

When you do tf.get_variable_scope().reuse_variables() you set the current scope to reuse variables. If you call the optimizer in such scope, it's trying to reuse slot variables, which it cannot find, so it throws an error. If you put a scope around, the tf.get_variable_scope().reuse_variables() only affects that scope, so when you exit it, you're back in the non-reusing mode, the one you want.

参考https://stackoverflow.com/questions/41986583/tensorflow-multi-gpu-example-error-variable-conv1-weights-exponentialmovingaver

3. 可以用github上及时更新维护的tensorflow例子, 包括mnist, cifar-10, AlexNet, ImageNet

https://github.com/tensorflow/models/tree/master/tutorials/image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值