'save', model_name, adv + '-' + str(eps) + '-' + str(int(n)) +
                '-' + str(eps_iter)))

    with open(
            os.path.join('dataset', 'random1024',
                         'whole_data_and_whole_label.pkl'), 'rb') as fid:
        whole_data, whole_label = pkl.load(fid)

    if args.model_name == 'PointNet2-SSG':
        from pointnet2.models.pointnet2_ssg_cls import Pointnet2SSG
        model = Pointnet2SSG(40, input_channels=0)  # , use_xyz=True)
        ckpt = torch.load(
            'checkpoints_ssg/pointnet2_cls_best.pth.tar')['model_state']
    elif args.model_name == 'PointNet2-MSG':
        from pointnet2.models.pointnet2_msg_cls import Pointnet2MSG
        model = Pointnet2MSG(40, input_channels=0)  # , use_xyz=True)
        ckpt = torch.load(
            'checkpoints_msg/pointnet2_cls_best.pth.tar')['model_state']
    else:
        print('No such model architecture')
        assert False

    model = model.to(device)
    model.load_state_dict(torch.load(checkpoint))
    model.eval()

    pytorch_utils.requires_grad_(model, False)

    print("Model name\t%s" % model_name)

    cnt = 0  # adv pointcloud successfully attacked
Esempio n. 2
0
def test_xyz():
    model = Pointnet2MSG(3, input_channels=3)
    pytest.helpers.cls_test_xyz(model, model_fn_decorator(nn.CrossEntropyLoss()))