(self, x)
| 29 | self.fc = nn.Linear(self.num_features, self.args.num_classes, bias=False) |
| 30 | |
| 31 | def forward_metric(self, x): |
| 32 | x = self.encode(x) |
| 33 | if 'cos' in self.mode: |
| 34 | x = F.linear(F.normalize(x, p=2, dim=-1), F.normalize(self.fc.weight, p=2, dim=-1)) |
| 35 | x = self.args.temperature * x |
| 36 | |
| 37 | elif 'dot' in self.mode: |
| 38 | x = self.fc(x) |
| 39 | x = self.args.temperature * x |
| 40 | return x |
| 41 | |
| 42 | def encode(self, x): |
| 43 | x = self.encoder(x) |