MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / __init__

Method __init__

timm/models/layers/eca.py:121–134  ·  view source on GitHub ↗
(self, channels=None, kernel_size=3, gamma=2, beta=1, act_layer=None, gate_layer='sigmoid')

Source from the content-addressed store, hash-verified

119 """
120
121 def __init__(self, channels=None, kernel_size=3, gamma=2, beta=1, act_layer=None, gate_layer='sigmoid'):
122 super(CecaModule, self).__init__()
123 if channels is not None:
124 t = int(abs(math.log(channels, 2) + beta) / gamma)
125 kernel_size = max(t if t % 2 else t + 1, 3)
126 has_act = act_layer is not None
127 assert kernel_size % 2 == 1
128
129 # PyTorch circular padding mode is buggy as of pytorch 1.4
130 # see https://github.com/pytorch/pytorch/pull/17240
131 # implement manual circular padding
132 self.padding = (kernel_size - 1) // 2
133 self.conv = nn.Conv1d(1, 1, kernel_size=kernel_size, padding=0, bias=has_act)
134 self.gate = create_act_layer(gate_layer)
135
136 def forward(self, x):
137 y = x.mean((2, 3)).view(x.shape[0], 1, -1)

Callers

nothing calls this directly

Calls 2

create_act_layerFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected