Load Pytorch Model Error in Python

I have this Issue when try to load Pytorch Model

this is the code:

LOAD MODEL

device, epoch, model_name, model, optimizer_name,\

optimizer, optimizer_opts, loss_name, loss_func, weight_g,\

loss_history, loss_history_for_batch, valid_history,\

f2_score_history, epoch_loss_history, total_time_min = machine.load(

model_file, gpu_id

)

And show me this Error:

RuntimeError: Error(s) in loading state_dict for VGG11:
size mismatch for linear_layers.6.weight: copying a param with shape torch.Size([3, 4096]) from checkpoint, the shape in current model is torch.Size([1, 4096]).
size mismatch for linear_layers.6.bias: copying a param with shape torch.Size([3]) from checkpoint, the shape in current model is torch.Size([1]).

Based on the error message it seems machine.load initializes a model (VGG11) with a linear_layers nn.Sequential container and runs into a shape mismatch in layer6, which seems to be an nn.Linear module. I don’t know if this is the output layer, but if so I would guess your state_dict was stored from a model using a different number of classes than what is initialized in machine.load.