LINUX 测试resnet18时,找不到模型 no checkpoint fount

输入(试了两次,都会报错)

python test.py --config /home/lidaiyuan/cg/FeatherNets_forNir/cfgs/ResNet-18.yaml --resume /home/lidaiyuan/cg/FeatherNets_forNir/checkpoints/ResNet18_test0723 --val True

报错:

/home/lidaiyuan/cg/FeatherNets_forNir
=> no checkpoint found at '/home/lidaiyuan/cg/FeatherNets_forNir/checkpoints/ResNet18_test0723'

以及

python test.py --config ./cfgs/ResNet-18.yaml --resume ./checkpoints/ResNet18_test0723 --val True

 导入模型部分代码

# optionally resume from a checkpoint
    if args.resume:
        print(os.getcwd())
        if os.path.isfile(args.resume):
            print("=> loading checkpoint '{}'".format(args.resume))
            checkpoint = torch.load(args.resume)
            args.start_epoch = checkpoint['epoch']
            best_prec1 = checkpoint['best_prec1']
            model.module.load_state_dict(checkpoint['model'])
            optimizer.load_state_dict(checkpoint['optimizer'])
            print("=> loaded checkpoint '{}' (epoch {})"
                  .format(args.resume, checkpoint['epoch']))
        else:
            print("=> no checkpoint found at '{}'".format(args.resume))

最后发现这torch.load(args.resume)是打开文件,不是打开文件夹,所有的模型都保存在

/ResNet18_test0723

而模型是

./checkpoints/ResNet18_test0723/_0_best.pth.tar

 

你可能感兴趣的:(linux)