(a, layer)
| 107 | |
| 108 | @staticmethod |
| 109 | def conv2d(a, layer): |
| 110 | batch_size = a.size(0) |
| 111 | a = _extract_patches(a, layer.kernel_size, layer.stride, layer.padding) |
| 112 | spatial_size = a.size(1) * a.size(2) |
| 113 | a = a.view(-1, a.size(-1)) |
| 114 | if layer.bias is not None: |
| 115 | a = torch.cat([a, a.new(a.size(0), 1).fill_(1)], 1) |
| 116 | a = a/spatial_size |
| 117 | # FIXME(CW): do we need to divide the output feature map's size? |
| 118 | return a.t() @ (a / batch_size) |
| 119 | |
| 120 | @staticmethod |
| 121 | def linear(a, layer): |
no test coverage detected