MCPcopy Create free account
hub / github.com/TimSeizinger/Bokehlicious / backward

Method backward

method/nn_util.py:223–234  ·  view source on GitHub ↗
(ctx, grad_output)

Source from the content-addressed store, hash-verified

221
222 @staticmethod
223 def backward(ctx, grad_output):
224 eps = ctx.eps
225
226 N, C, H, W = grad_output.size()
227 y, var, weight = ctx.saved_variables
228 g = grad_output * weight.view(1, C, 1, 1)
229 mean_g = g.mean(dim=1, keepdim=True)
230
231 mean_gy = (g * y).mean(dim=1, keepdim=True)
232 gx = 1. / sqrt(var + eps) * (g - y * mean_gy - mean_g)
233 return gx, (grad_output * y).sum(dim=3).sum(dim=2).sum(dim=0), grad_output.sum(dim=3).sum(dim=2).sum(
234 dim=0), None
235
236class LayerNorm2d(nn.Module):
237

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected