nmhkahn / torchsummaryX

torchsummaryX: Improved visualization tool of torchsummary
302 stars 32 forks source link

A problem about the input tensor. #13

Closed fourierer closed 4 years ago

fourierer commented 4 years ago

Hello, I wanna use this tool to calculate params and flops of GhostNet model, which is proposed in CVPR2020. I met an error when I set different input tensors. (1) summary(model, torch.zeros(2, 3, 224, 224)) It can work correctly; (2) summary(model, torch.zeros(1, 3, 224, 224)) There is an error "ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 1280])" Is this normal? Does it calculate the params and the flops correctly when I set the N to 2?

nmhkahn commented 4 years ago

Hi. It because nn.BatchNorm1d does not accept batch_size=1 on the training phase. If you first call .eval() then I guess it works.

fourierer commented 4 years ago

Hi. It because nn.BatchNorm1d does not accept batch_size=1 on the training phase. If you first call .eval() then I guess it works.

Thank you so much for your reply!