model_dict.update(pretrain_dict)
model.load_state_dict(model_dict)
print("Initialized model with pretrained weights from {}".format(model_url))
print("Imagenet weights unavailable")
def resnext50_32x4d(num_classes, loss, pretrained="imagenet", **kwargs):
model = ResNeXt(
After Change
Layers that don"t match with pretrained layers in name or size are kept unchanged.
pretrain_dict = model_zoo.load_url(model_url)
model_dict = model.state_dict()
pretrain_dict = {k: v for k, v in pretrain_dict.items() if k in model_dict and model_dict[k].size() == v.size()}
model_dict.update(pretrain_dict)
model.load_state_dict(model_dict)
print("Initialized model with pretrained weights from {}".format(model_url))
def resnext50_32x4d(num_classes, loss, pretrained="imagenet", **kwargs):