Swall0w / torchstat

Model analyzer in PyTorch
MIT License
1.46k stars 144 forks source link

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

Open OpenAI-chn opened 2 years ago

OpenAI-chn commented 2 years ago
np.array(output.size()[1:], dtype=np.int32))

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

Beta-Hu commented 2 years ago

I have meet the same problem today, and it may caused by a MaxPool2d operation with argument _returnindices=True, because when requires indices, MaxPool2d will return a tuple, rather than a Tensor when _returnindices=False. 这可能是因为你将MaxPool2d的参数return_indices设置为了True,此时MaxPool2d返回的是一个包含池化结果和下标的元组。