0
votes

I am trying to understand why the shape of the output logits from the Resnet18 model I am working with are (27, 19). The shape of 19 I understand, that is the number of classes I have set the model to predict, but the shape of 27 is the part that I am confused about. I have a batch size of 64 so I would have thought the shape of the logits would be (64, 19), because that would give me 1 prediction vector for each image in the batch...

2
It should be. Is it possible you've transposed your data somehow so the batch size is being treated as an image dimension and convolved on? - c2huc2hu
Ah you know what, its because I was looking at the logits from the last batch in my epoch, and I guess there wasn't enough images left to fill up the entire 64 batch size so it only has 27 images left to train on. - Steve Ahlswede
@SteveAhlswede if so, please post a self-answer, thanks - Szymon Maszke

2 Answers

2
votes

Turns out I was looking at the logits from the last batch in my epoch, and there weren't enough images left to fill up the entire 64 batch size so it only has 27 images left to train on.

1
votes

You got it.

The Torch dataloader did this because the method drop_last defaults to False. If you set it to True, it will only output logits shape (64, 19)

https://pytorch.org/docs/stable/data.html