and also i try  another code in testing  the model,do i have to modify the resnet model again in testing the saving model?
import torch
import torch.nn as nn
#from torchvision import models
#from future import print_function
import argparse
#import torch
#from torch.autograd import Variable
from PIL import Image
#from torchvision.transforms import ToTensor
import torchvision.models as models
import skimage.io 2
from torch.autograd import Variable as V
from torch.nn import functional as f
from torchvision import transforms as trn
# define image transformation
centre_crop = trn.Compose([
        trn.ToPILImage(),
        trn.Scale(256),
        trn.CenterCrop(224),
        trn.ToTensor(),
        trn.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
filename=r'2780-0-20161221_0001.jpg'
img = skimage.io.imread(filename)
x = V(centre_crop(img).unsqueeze(0), volatile=True)

model = models.__dict__['resnet18']()
model.fc=nn.Linear(512,100)
checkpoint = torch.load('model_best1.pth.tar')
best_prec1 = checkpoint['best_prec1']
model.load_state_dict(checkpoint['state_dict'])
model = torch.nn.DataParallel(model).cuda()
logit = model(x)
print(logit)
print(len(logit))
h_x = f.softmax(logit).data.squeeze()

an error occured ,i have no idea why
TM2%0$$WTD4NME}`M4{BRBW.png887×394 7.72 KB