(self, inpt)
| 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 | |
| 86 | class InstantLayerNorm2d(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected