0

I am dealing with variable sized inputs to a CNN and I wanted to know how to feed it to a last FC layer to satisfy the requirement for the CrossEntropy Loss function. Even if taken care for one sample, the subsequent sample would have different dimensions and can't be used in backpropagation. So I wanted to know a way or different ways this can be handled.

(P.S : Cropping the input to make it fixed size is being currently used and the query is for improvising)

1 Answers1

1

Just place torch.nn.AdaptiveAvgPool2d(S) right between your Last conv layers and 1st Fully connected layer.

Note that your fully connected layer should take input dimension of S x S x no. of channels in last conv layer

Prajot Kuvalekar
  • 5,128
  • 3
  • 21
  • 32
  • Thank you very much for that, that seemed to work. However, I was further wondering how it modifies the data and plays an impact the model and the results. I understand it is task specific but as I fail to send batches of different length data to the model, I was wondering if there is a way to send batches of variable data too. – Dheeraj P R Feb 18 '21 at 22:01