| 250 | |
| 251 | class Encoder(nn.Module): |
| 252 | def __init__(self, num_layers, r1, r2, num_f_maps, input_dim, num_classes, channel_masking_rate, att_type, alpha): |
| 253 | super(Encoder, self).__init__() |
| 254 | self.conv_1x1 = nn.Conv1d(input_dim, num_f_maps, 1) # fc layer |
| 255 | self.layers = nn.ModuleList( |
| 256 | [AttModule(2 ** i, num_f_maps, num_f_maps, r1, r2, att_type, 'encoder', alpha) for i in # 2**i |
| 257 | range(num_layers)]) |
| 258 | |
| 259 | self.conv_out = nn.Conv1d(num_f_maps, num_classes, 1) |
| 260 | self.dropout = nn.Dropout2d(p=channel_masking_rate) |
| 261 | self.channel_masking_rate = channel_masking_rate |
| 262 | |
| 263 | def forward(self, x, mask): |
| 264 | ''' |