If you still need help , i encountered a similar problem and found a way to work around.
I was facing this problem because my batch size was 64 and total datapoints / samples were 20000 so the last batch couldn’t be divided into 64 and i got size mismatch error. This was because i hardcoded into the first linear layers after all conv layers like this :
self.lin1 = nn.Linear(out.reshape(64,8*20*20))
instead of doing this , I passed the length of each training batch as a parameter to the forward function.
and passed len(xb) as the parameter and changed self.lin1 to  self.lin1 = nn.Linear(out.reshape(batch_size , 8*20*20))
where batch_size is the current batch size.
Well i also missed that you could always do nn.Linear(out.reshape(-1,8*20*20))
Without sending a batch size parameter manually.