简体   繁体   English

澄清批量标准化如何在 Tensorflow 上工作

[英]Clarification of how Batch normalization works on Tensorflow

To better understand how the BN works, I have decided to code my batch normalization and compare it to the TF implementation.为了更好地理解 BN 的工作原理,我决定编写批量标准化代码并将其与 TF 实现进行比较。 I made a simple example (image attached).我做了一个简单的例子(附图片)。 I computed the mean and variance for each channel across the batches, as illustrated in the image.如图所示,我计算了批次中每个通道的均值和方差。 After that, I normalized the data using the formulation presented in the BN paper , subtracted by the mean, and divided by the root of the variance (I am not using the scaled factor nor the shift).之后,我使用 BN论文中提出的公式对数据进行归一化,减去均值,然后除以方差的根(我没有使用比例因子也没有使用移位)。 Then, I used the function tf.keras.layers.BatchNormalization(center=False, scale=False) from TF.然后,我使用了来自 TF 的 function tf.keras.layers.BatchNormalization(center=False, scale=False)。 The results were completely different.结果完全不同。

I would like some help to clarify how the batch normalization (BN) is performed on TensorFlow (TF) and if anyone has some insight into why the results were so different from TF.我想要一些帮助来澄清如何在 TensorFlow (TF) 上执行批量标准化 (BN),以及是否有人对为什么结果与 TF 如此不同有所了解。

Thank you.谢谢你。

在此处输入图像描述

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

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