(self, x, y=None)
| 98 | ) |
| 99 | |
| 100 | def forward(self, x, y=None): |
| 101 | x_size = x.size() |
| 102 | assert (x_size[2]-1) % 8 == 0 and (x_size[3]-1) % 8 == 0 |
| 103 | h = int((x_size[2] - 1) / 8 * self.zoom_factor + 1) |
| 104 | w = int((x_size[3] - 1) / 8 * self.zoom_factor + 1) |
| 105 | |
| 106 | x = self.layer0(x) |
| 107 | x = self.layer1(x) |
| 108 | x = self.layer2(x) |
| 109 | x_tmp = self.layer3(x) |
| 110 | x = self.layer4(x_tmp) |
| 111 | |
| 112 | if self.use_ppm: |
| 113 | x = self.ppm(x) |
| 114 | x = self.cls(x) |
| 115 | if self.zoom_factor != 1: |
| 116 | x = F.interpolate(x, size=(h, w), mode='bilinear', align_corners=True) |
| 117 | |
| 118 | if self.training: |
| 119 | aux = self.aux(x_tmp) |
| 120 | if self.zoom_factor != 1: |
| 121 | aux = F.interpolate(aux, size=(h, w), mode='bilinear', align_corners=True) |
| 122 | main_loss = self.criterion(x, y) |
| 123 | aux_loss = self.criterion(aux, y) |
| 124 | return x.max(1)[1], main_loss, aux_loss |
| 125 | else: |
| 126 | return x |
| 127 | |
| 128 | |
| 129 | if __name__ == '__main__': |
nothing calls this directly
no outgoing calls
no test coverage detected