I think the easiest approach would be to load the state_dict completely and reset the last layer’s state_dict:
modelA = models.resnet18(pretrained=True)
modelB = models.resnet18()

fc_sd = copy.deepcopy(modelB.fc.state_dict())
modelB.load_state_dict(modelA.state_dict())
modelB.fc.load_state_dict(fc_sd)

for (nameA, paramA), (nameB, paramB) in zip(modelA.named_parameters(), modelB.named_parameters()):
    if (paramA == paramB).all():
        print('{} matches {}'.format(nameA, nameB))
    else:
        print('{} does not match {}'.format(nameA, nameB))