Thank you @ptrblck for your response.
The solution that you have provided is working well, and I could see my model’s architecture and layers. Now, I want to do transfer learning, so, I need to load the model’s weights from “mobilevit_s.pt”, but I am getting an error. Here is my code:
net = MobileViT_S()
net.load_state_dict(torch.load(MODELS_PATH + "MobileViT_S_model_best.pth.tar", map_location=torch.device('cpu')))
print(net)
I have got the following error in load_state_dict function:
RuntimeError: Error(s) in loading state_dict for MobileViT:
Missing key(s) in state_dict: "stem.0.weight", "stem.0.bias", "stem.1.conv.0.conv.weight", "stem.1.conv.0.norm_layer.weight", "stem.1.conv.0.norm_layer.bias", "stem.1.conv.0.norm_layer.running_mean", "stem.1.conv.0.norm_layer.running_var", "stem.1.conv.1.conv.weight", "stem.1.conv.1.norm_layer.weight", "stem.1.conv.1.norm_layer.bias", "stem.1.conv.1.norm_layer.running_mean", "stem.1.conv.1.norm_layer.running_var", "stem.1.conv.2.weight", "stem.1.conv.3.weight", "stem.1.conv.3.bias", "stem.1.conv.3.running_mean", "stem.1.conv.3.running_var", "stage1.0.conv.0.conv.weight", "stage1.0.conv.0.norm_layer.weight", "stage1.0.conv.0.norm_layer.bias", "stage1.0.conv.0.norm_layer.running_mean", "stage1.0.conv.0.norm_layer.running_var", "stage1.0.conv.1.conv.weight", "stage1.0.conv.1.norm_layer.weight", "stage1.0.conv.1.norm_layer.bias", "stage1.0.conv.1.norm_layer.running_mean", "stage1.0.conv.1.norm_layer.running_var", "stage1.0.conv.2.weight", "stage1.0.conv.3.weight", "stage1.0.conv.3.bias", "stage1.0.conv.3.running_mean", "stage1.0.conv.3.running_var", "stage1.1.conv.0.conv.weight", "stage1.1.conv.0.norm_layer.weight", "stage1.1.conv.0.norm_layer.bias", "stage1.1.conv.0.norm_layer.running_mean", "stage1.1.conv.0.norm_layer.running_var", "stage1.1.conv.1.conv.weight", "stage1.1.conv.1.norm_layer.weight", "stage1.1.conv.1.norm_layer.bias", "stage1.1.conv.1.norm_layer.running_mean", "stage1.1.conv.1.norm_layer.running_var", "stage1.1.conv.2.weight", "stage1.1.conv.3.weight", "stage...
Unexpected key(s) in state_dict: "epoch", "state_dict", "best_acc1", "optimizer".```