(self, x)
| 98 | parameters.requires_grad = False |
| 99 | |
| 100 | def forward(self, x): |
| 101 | out_featList = [] |
| 102 | feature = x |
| 103 | cnt = 0 |
| 104 | block_cnt = 0 |
| 105 | for k, v in self.encoder._modules.items(): |
| 106 | if k == 'act2': |
| 107 | break |
| 108 | if k == 'blocks': |
| 109 | for m, n in v._modules.items(): |
| 110 | feature = n(feature) |
| 111 | try: |
| 112 | if self.block_idx[block_cnt] == cnt: |
| 113 | out_featList.append(feature) |
| 114 | block_cnt += 1 |
| 115 | break |
| 116 | cnt += 1 |
| 117 | except: |
| 118 | continue |
| 119 | else: |
| 120 | feature = v(feature) |
| 121 | if self.block_idx[block_cnt] == cnt: |
| 122 | out_featList.append(feature) |
| 123 | block_cnt += 1 |
| 124 | break |
| 125 | cnt += 1 |
| 126 | |
| 127 | return out_featList |
| 128 | |
| 129 | def freeze_bn(self, enable=False): |
| 130 | """ Adapted from https://discuss.pytorch.org/t/how-to-train-with-frozen-batchnorm/12106/8 """ |
nothing calls this directly
no outgoing calls
no test coverage detected