Solved by ptrblck in post #2 
              
              
                I cannot reproduce this issue by using an input tensor of [batch_size, 3, 416, 416] and am running into a shape mismatch error before. 
Changing x.view(-1, 2048) to x.view(x.size(0), -1) and adapting the expected in_features in self.linear works: 
num_classes = 20
class Net(nn.Module):
    def __ini…