Hi,
I am using vgg16 pre-train model . I have replaced the classifier with following
classifier = nn.Sequential(OrderedDict([
    ('fc1', nn.Linear(input_size, hidden_sizes[0])),
    ('relu_fc1', nn.ReLU()),
    ('drop_fc1',nn.Dropout(drop_p)),
    ('fc2', nn.Linear(hidden_sizes[0], hidden_sizes[1])),
    ('relu_fc2', nn.ReLU()),
    ('drop_fc2',nn.Dropout(drop_p)),
    ('output', nn.Linear(hidden_sizes[1], output_size)),
    ('LogSoftmax', nn.LogSoftmax(dim=1))
    ]))
model.classifier = classifier

Now when I test the image
output = model.forward(toImg)

I get following error
/opt/conda/lib/python3.6/site-packages/torch/nn/functional.py in linear(input, weight, bias)
990     if input.dim() == 2 and bias is not None:
991         # fused op is marginally faster
–> 992         return torch.addmm(bias, input, weight.t())
993
994     output = input.matmul(weight.t())
RuntimeError: size mismatch, m1: [1 x 18432], m2: [25088 x 4096] at /opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/generic/THCTensorMathBlas.cu:249