Update running_mean_std.py (#585)

This commit is contained in:
Xingdong Zuo
2018-09-18 23:14:38 +02:00
committed by pzhokhov
parent 59662fff78
commit d34049cab4

View File

@@ -26,9 +26,9 @@ def update_mean_var_count_from_moments(mean, var, count, batch_mean, batch_var,
new_mean = mean + delta * batch_count / tot_count
m_a = var * count
m_b = batch_var * batch_count
M2 = m_a + m_b + np.square(delta) * count * batch_count / (count + batch_count)
new_var = M2 / (count + batch_count)
new_count = batch_count + count
M2 = m_a + m_b + np.square(delta) * count * batch_count / tot_count
new_var = M2 / tot_count
new_count = tot_count
return new_mean, new_var, new_count