module Chainer::Functions::Normalization::Calculation
Public Instance Methods
apply_bn_fwd(xp, x, mean, inv_std, gamma, beta)
click to toggle source
# File lib/chainer/functions/normalization/batch_normalization.rb, line 5 def apply_bn_fwd(xp, x, mean, inv_std, gamma, beta) # NOTE: all arguments should be broadcasted to x.shape # (mean, inv_std, gamma, and beta have to already be expanded) x_hat = x_hat(x, mean, inv_std) y = gamma * x_hat y += beta y end
x_hat(x, mean, inv_std)
click to toggle source
# File lib/chainer/functions/normalization/batch_normalization.rb, line 14 def x_hat(x, mean, inv_std) x_mu = x - mean x_mu *= inv_std x_mu end
zero_if_none(xp, x, shape, dtype)
click to toggle source
# File lib/chainer/functions/normalization/batch_normalization.rb, line 20 def zero_if_none(xp, x, shape, dtype) # TODO: Return broadcasted 0 instead of a zeroed array. x.nil? ? dtype.zeros(*shape) : x end