AttributeError: 'tuple' object has no attribute 'size'

问题遇到的现象和发生背景

AttributeError: 'tuple' object has no attribute 'size'

遇到的现象和发生背景,请写出第一个错误信息

AttributeError: 'tuple' object has no attribute 'size'

用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
class Net(torch.nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.lstm = nn.LSTM(input_size=M,
                            hidden_size=128,
                            num_layers=2,
                            batch_first=False,
                            )
        self.out = nn.Linear(128, N)
        self.seattention = SEAttention(channel=64,reduction=8)

    def forward(self, inputs, hidden):
        r_out, hidden = self.lstm(inputs, hidden)
        hidden = self.seattention(hidden)
        outputs = self.out(r_out[-1, :, :])
        return outputs, hidden


运行结果及详细报错内容

Traceback (most recent call last):
File "D:\YU\资料\PSSE_Code-master\LSTM\IEEE14\IEEE142.py", line 571, in
main()
File "D:\YU\资料\PSSE_Code-master\LSTM\IEEE14\IEEE142.py", line 567, in main
pfm_test()
File "D:\YU\资料\PSSE_Code-master\LSTM\IEEE14\IEEE142.py", line 539, in pfm_test
outputs, hidden = estimator(inputs2, hidden)
File "C:\Users\22810\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "D:\YU\资料\PSSE_Code-master\LSTM\IEEE14\IEEE142.py", line 158, in forward
hidden = self.seattention(hidden)
File "C:\Users\22810\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\22810\AppData\Local\Programs\Python\Python38\lib\site-packages\fightingcv_attention\attention\SEAttention.py", line 36, in forward
b, c, _, _ = x.size()
AttributeError: 'tuple' object has no attribute 'size'

我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%

思路毫无头绪

我想要达到的结果,如果你需要快速回答,请尝试 “付费悬赏”

解决这个问题

看上去你没有截到关键的信息,.size()在哪个地方