写一段Batch normalization 的python代码
时间: 2023-03-12 19:55:53 浏览: 101
理解Batch Normalization(含实现代码)
5星 · 资源好评率100%
示例:
import numpy as npdef batchnorm(X, gamma, beta, epsilon=1e-5):
# 计算均值
mu = np.mean(X, axis=0)
# 计算方差
var = np.var(X, axis=0)
# 计算X的标准差
std = np.sqrt(var + epsilon)
# 计算X的标准分布
z = (X - mu) / std
# 计算batch normalization
out = gamma * z + beta
return out
阅读全文