简体   繁体   English

多 GPU tensorflow 代码中的批量标准化参数更新?

[英]batch normalization parameters update in multi gpu tensorflow code?

I have written a multi gpu Cnn code我写了一个多 GPU Cnn 代码

In this link they commented in line 249此链接中,他们在第 249 行评论

# Retain the Batch Normalization updates operations only from the # final tower. # 仅保留来自最终塔的批量标准化更新操作。 Ideally, we should grab the updates from all towers # but these stats accumulate extremely fast so we can ignore the # other stats from the other towers without significant detriment.理想情况下,我们应该从所有塔中获取更新 # 但这些统计数据累积得非常快,因此我们可以忽略来自其他塔的 # 其他统计数据而不会造成重大损失。

but this code of updating batch norm(in line 253) :但是这个更新批处理规范的代码(在第 253 行):

with tf.device('/gpu:%d' % i):
.
.
.
  batchnorm_updates = 
  tf.get_collection(slim.ops.UPDATE_OPS_COLLECTION,scope)

is done for all towers(GPUs) so what is the right place of this update?已针对所有塔(GPU)完成,那么此更新的正确位置是什么?

I think you understand the code incorrectly.我认为您错误地理解了代码。

as the for loop in the code ,作为代码中for loop

for i in range(FLAGS.num_gpus):
  with tf.device('/gpu:%d' % i):
    with tf.name_scope('%s_%d' % (inception.TOWER_NAME, i)) as scope:

      with slim.arg_scope([slim.variables.variable], device='/cpu:0'):

      ......

      batchnorm_updates = tf.get_collection(slim.ops.UPDATE_OPS_COLLECTION,
                                            scope)

the batchnorm_updates will be replaced after each for loop , so it just contains the last tower's Batch Normalization updates operations when the for loop is done. batchnorm_updates将在每个for loop后被替换,因此它只包含在for loop完成时最后一个塔的批量标准化更新操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM