When i load a model i am seeing this error?

I don’t understand the question since you won’t be able to load any arbitrary state_dict into the pretrained resnet as already explained.
Could you explain what your actual use case is and why you are trying to load an incompatible state_dict into the pretrained resnet?

@ptrblck sir, actually i am trying to load a pretrained CNN model and trying to train the model, thats y i need to load the model.i want to know how to train a pretrained cnn model?

Create the new model object after fixing the previous error here and call load_state_dict on it as given in your previous code snippet here.
It’s unclear why you are suddenly changing the model from tinyvgg1 to a resnet causing these new issues.

@ptrblck i dont know how to train a p retrained cnn model, i saved that cnn model i you asked earlier, i cleared the error,but i need to train that saved model again, so i asked chat gpt, it showed me model = model.resnet18(pretrained=True) like i tried and showed me error, but, i also thought the same thing, it is not possible for loadstate_dict into a resnet.

@ptrblck sir can you help me to train pretrain cnn model?

@hello sir, how to know which architecture good for me to load the pretrained model?

ChatGPT is wrong as it suggested to change the model, which doesn’t make sense.

You can just restore the model directly, load the state_dict, and continue training.
You’ve already trained the model before and after restoring its state_dict just continue training with a new Dataset, DataLoader, etc.

@ptrblck sir, i want to load cnn model without explicitly defining an nn.Module class,i s there anyway to do this?