遇到报错AssertionError
Successfully loaded first 20 categories for training and last 20 for testing!
Traceback (most recent call last):
File "D:\d.py", line 1438, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\e.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/t.py", line 349, in <module>
main()
File "E:/t.py", line 298, in main
_init_(args)
File "E:/t.py", line 339, in _init_
assert os.path.isfile(args.pretrained1)
AssertionError
部分代码
def _init_(args):
if not os.path.exists('checkpoints'):
os.makedirs('checkpoints')
if not os.path.exists('checkpoints/' + args.exp_name):
os.makedirs('checkpoints/' + args.exp_name)
if not os.path.exists('checkpoints/' + args.exp_name + '/' + 'models'):
os.makedirs('checkpoints/' + args.exp_name + '/' + 'models')
trainset = RegistrationData(ModelNet40Data(train=True, num_points=args.num_points, unseen=args.unseen),
partial_source=args.partial_source, noise=args.noise, outliers=args.outliers)
testset = RegistrationData(ModelNet40Data(train=False, num_points=args.num_points, unseen=args.unseen),
partial_source=args.partial_source, noise=args.noise, outliers=args.outliers)
train_loader = DataLoader(trainset, batch_size=args.batch_size, shuffle=True, drop_last=True, num_workers=args.workers)
test_loader = DataLoader(testset, batch_size=args.test_batch_size, shuffle=False, drop_last=False, num_workers=args.workers)
if not torch.cuda.is_available():
args.device = 'cpu'
args.device = torch.device(args.device)
model = tpccNet()
model = model.to(args.device)
ptnet = PointNet(emb_dims=args.emb_dims)
model2 = itmpeNet(feature_model=ptnet)
model2 = model2.to(args.device)
checkpoint = None
if args.resume:
assert os.path.isfile(args.resume)
checkpoint = torch.load(args.resume)
args.start_epoch = checkpoint['epoch'] #Here checkpoint is used to call the saved model to continue training
model2.load_state_dict(checkpoint['model2'])
if args.pretrained1:
assert os.path.isfile(args.pretrained1) #这里报错
model.load_state_dict(torch.load(args.pretrained1, map_location='cpu'))
model.to(args.device)
if args.eval:
test(args, model, model2, test_loader, textio)
else:
train(args, model, model2, train_loader, test_loader, boardio, textio, checkpoint)