MCPcopy Create free account
hub / github.com/dangf15/THLNet / forward

Method forward

utils.py:77–83  ·  view source on GitHub ↗
(self, inpt)

Source from the content-addressed store, hash-verified

75 self.bias = Variable(torch.zeros(1, 1, num_features), requires_gra=False)
76
77 def forward(self, inpt):
78 # inpt: (T,B,C)
79 seq_len, b_size, channel = inpt.shape
80 ins_mean = torch.mean(inpt, dim=-1, keepdim=True) # (T,B,1)
81 ins_std = (torch.var(inpt, dim=-1, keepdim=True) + self.eps).pow(0.5) # (T,B,1)
82 x = (inpt - ins_mean) / ins_std
83 return x * self.gain.expand_as(x).type(x.type()) + self.bias.expand_as(x).type(x.type())
84
85
86class InstantLayerNorm2d(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected