MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / conv2d

Method conv2d

optimizers/kfac_utils.py:109–118  ·  view source on GitHub ↗
(a, layer)

Source from the content-addressed store, hash-verified

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):

Callers 3

__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45

Calls 1

_extract_patchesFunction · 0.70

Tested by

no test coverage detected