| 4 | |
| 5 | |
| 6 | class Model(nn.Module): |
| 7 | def __init__(self, input_len, num_classes): |
| 8 | super(Model, self).__init__() |
| 9 | self.model = models.resnet50(num_classes=num_classes) |
| 10 | self.model.conv1 = torch.nn.Conv2d(input_len, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False) |
| 11 | |
| 12 | ##Weights init |
| 13 | nn.init.kaiming_normal_(self.model.conv1.weight, mode='fan_out', nonlinearity='relu') |
| 14 | |
| 15 | self.softmax = nn.Softmax(dim=1) |
| 16 | |
| 17 | def forward(self, x): |
| 18 | x = self.model(x) |
| 19 | if not self.training: |
| 20 | x = self.softmax(x) |
| 21 | return x |