MCPcopy Create free account
hub / github.com/ChinaYi/ASFormer / Decoder

Class Decoder

model.py:284–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282
283
284class Decoder(nn.Module):
285 def __init__(self, num_layers, r1, r2, num_f_maps, input_dim, num_classes, att_type, alpha):
286 super(Decoder, self).__init__()# self.position_en = PositionalEncoding(d_model=num_f_maps)
287 self.conv_1x1 = nn.Conv1d(input_dim, num_f_maps, 1)
288 self.layers = nn.ModuleList(
289 [AttModule(2 ** i, num_f_maps, num_f_maps, r1, r2, att_type, 'decoder', alpha) for i in # 2 ** i
290 range(num_layers)])
291 self.conv_out = nn.Conv1d(num_f_maps, num_classes, 1)
292
293 def forward(self, x, fencoder, mask):
294
295 feature = self.conv_1x1(x)
296 for layer in self.layers:
297 feature = layer(feature, fencoder, mask)
298
299 out = self.conv_out(feature) * mask[:, 0:1, :]
300
301 return out, feature
302
303class MyTransformer(nn.Module):
304 def __init__(self, num_decoders, num_layers, r1, r2, num_f_maps, input_dim, num_classes, channel_masking_rate):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected