EfficientNet's forward function. Calls extract_features to extract features, applies final linear layer, and returns logits. Args: inputs (tensor): Input tensor. Returns: Output of this model after processing.
(self, inputs)
| 477 | return x |
| 478 | |
| 479 | def forward(self, inputs): |
| 480 | """EfficientNet's forward function. |
| 481 | Calls extract_features to extract features, applies final linear layer, and returns logits. |
| 482 | Args: |
| 483 | inputs (tensor): Input tensor. |
| 484 | Returns: |
| 485 | Output of this model after processing. |
| 486 | """ |
| 487 | # Convolution layers |
| 488 | # x = self.extract_features(inputs) |
| 489 | endpoints = self.extract_endpoints(inputs) |
| 490 | x1 = endpoints['reduction_6'] |
| 491 | x2 = endpoints['reduction_5'] |
| 492 | x3 = endpoints['reduction_4'] |
| 493 | x4 = endpoints['reduction_3'] |
| 494 | x5 = endpoints['reduction_2'] |
| 495 | x = x1 |
| 496 | |
| 497 | if self._global_params.include_top: |
| 498 | # Pooling and final linear layer |
| 499 | x = self._avg_pooling(x) |
| 500 | |
| 501 | x = x.flatten(start_dim=1) |
| 502 | x = self._dropout(x) |
| 503 | x = self._fc(x) |
| 504 | return x |
| 505 | |
| 506 | if self._global_params.include_hm_decoder: |
| 507 | x1 = self._dropout(x1) |
| 508 | x2 = self._dropout(x2) |
| 509 | x3 = self._dropout(x3) |
| 510 | x4 = self._dropout(x4) |
| 511 | |
| 512 | if self.efpn: |
| 513 | assert self._global_params.use_c51, "C51 must be utilized for FPN intergration" |
| 514 | |
| 515 | x = self.__getattr__('deconv_1')(x1) |
| 516 | |
| 517 | if self._global_params.use_c51: |
| 518 | x_weighted = self._sigmoid(x) |
| 519 | x_inv = torch.sub(1, x_weighted, alpha=1) |
| 520 | x2_ = torch.multiply(x_inv, x2) |
| 521 | x = torch.cat([x, x2_], dim=1) |
| 522 | |
| 523 | if self.se_layer: |
| 524 | x = self.__getattr__('se_layer_1')(x) |
| 525 | else: |
| 526 | x = self._relu(x) |
| 527 | |
| 528 | x = self.__getattr__('deconv_2')(x) |
| 529 | |
| 530 | if self._global_params.use_c4: |
| 531 | x_weighted = self._sigmoid(x) |
| 532 | x_inv = torch.sub(1, x_weighted, alpha=1) |
| 533 | x3_ = torch.multiply(x_inv, x3) |
| 534 | x = torch.cat([x, x3_], dim=1) |
| 535 | |
| 536 | if self.se_layer: |
nothing calls this directly
no test coverage detected