extract=False, dropout_p=args.dropout_p).cuda() netG.eval() netF.eval() for epoch in range(args.epoch / 2, args.epoch + 1): if epoch % 10 != 0: continue netG.load_state_dict( torch.load( os.path.join( args.snapshot, "Office31_HAFN_" + args.task + "_netG_" + args.post + "." + args.repeat + "_" + str(epoch) + ".pth"))) netF.load_state_dict( torch.load( os.path.join( args.snapshot, "Office31_HAFN_" + args.task + "_netF_" + args.post + "." + args.repeat + "_" + str(epoch) + ".pth"))) correct = 0 tick = 0 for (imgs, labels) in t_loader: tick += 1 imgs = Variable(imgs.cuda()) pred = netF(netG(imgs)) pred = F.softmax(pred) pred = pred.data.cpu().numpy() pred = pred.argmax(axis=1) labels = labels.numpy() correct += np.equal(labels, pred).sum() correct = correct * 1.0 / len(t_set)
netF = ResClassifier(class_num=args.class_num).cuda() netG.eval() netF.eval() for epoch in range(args.epoch / 2, args.epoch + 1): if epoch % 10 != 0: continue netG.load_state_dict( torch.load( os.path.join( args.snapshot, "VisDA_IAFN_netG_" + args.post + '.' + str(args.repeat) + '_' + str(epoch) + ".pth"))) netF.load_state_dict( torch.load( os.path.join( args.snapshot, "VisDA_IAFN_netF_" + args.post + '.' + str(args.repeat) + '_' + str(epoch) + ".pth"))) correct = 0 tick = 0 for (imgs, labels) in t_loader: tick += 1 imgs = Variable(imgs.cuda()) pred = netF(netG(imgs)) pred = F.softmax(pred) pred = pred.data.cpu().numpy() pred = pred.argmax(axis=1) labels = labels.numpy() correct += np.equal(labels, pred).sum()
netG = ResBase50().cuda() netF = ResClassifier(class_num=args.class_num, extract=False).cuda() netG.eval() netF.eval() for epoch in range(1, args.epoch + 1): if epoch % 10 != 0: continue netG.load_state_dict( torch.load( os.path.join( args.snapshot, "OfficeHome_IAFN_" + args.task + "_netG_" + args.post + '.' + args.repeat + '_' + str(epoch) + ".pth"))) netF.load_state_dict( torch.load( os.path.join( args.snapshot, "OfficeHome_IAFN_" + args.task + "_netF_" + args.post + '.' + args.repeat + '_' + str(epoch) + ".pth"))) correct = 0 tick = 0 for (imgs, labels) in t_loader: tick += 1 imgs = Variable(imgs.cuda()) pred = netF(netG(imgs)) pred = F.softmax(pred) pred = pred.data.cpu().numpy() pred = pred.argmax(axis=1) labels = labels.numpy() correct += np.equal(labels, pred).sum()