时间序列通道注意力模块

时间序列通道注意力模块_第1张图片


inspiration comes from SEnet

时间序列通道注意力模块_第2张图片

import torch
import torch.nn as nn
import math

class ts_channel_block(nn.Module):
    def __init__(self, channel, ratio=1):
        super(ts_channel_block, self).__init__()
        self.avg_pool = nn.AdaptiveAvgPool1d(1) #innovation
        self.fc = nn.Sequential(
                nn.Linear(channel, channel // ratio, bias=False),
                nn.ReLU(inplace=True),
                nn.Linear(channel // ratio, channel, bias=False),
                nn.Sigmoid()
        )

    def forward(self, x):
        b, c, l = x.size() # (B,C,L)
        # y = self.avg_pool(x) # (B,C,L) 通过avg=》 (B,C,1)
        # print("y",y.sha

你可能感兴趣的:(#,深度学习Pytorch框架,time,python,深度学习,pytorch)