Putting this here in case anyone is able to understand the docs more than me, but I'm trying to just load any model output from the torch addin into python. Anyone have any luck doing this? I'm hoping that I can just load the state dict of the given model I selected but that doesn't seem to be working.
# %%
from pathlib import Path
import torch
from torchvision.models import efficientnet_b2
# %%
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_path = Path(__file__).parent.parent/"models/VI Models/E353 EffNetB2 MLP DOR20"
model_paths = list(model_path.glob("*v1f1*.pt")) # just pick one model for now
# %%
model = efficientnet_b2(dropout=0.2).to(device)
# %%
model_paths[0].relative_to(model_path) # WindowsPath('tdl_jmp_v1f1_jnet.pt')
# %%
model_part = torch.jit.load(model_paths[0], map_location=device)
model_part
# %%
model.load_state_dict(model_part.state_dict())
# this fails with
# RuntimeError: Error(s) in loading state_dict for EfficientNet:
# Missing key(s) in state_dict: "features.0.0.weight", "features.0.1.weight", "features.0.1.bias", "features.0.1.running_mean", .... very long list
# Unexpected key(s) in state_dict: "0.0.0.weight", "0.0.1.weight", "0.0.1.bias", "0.0.1.running_mean", .... very long list
# %%