{"action":"opened","issue":{"url":"https://api.github.com/repos/bethgelab/foolbox/issues/141","repository_url":"https://api.github.com/repos/bethgelab/foolbox","labels_url":"https://api.github.com/repos/bethgelab/foolbox/issues/141/labels{/name}","comments_url":"https://api.github.com/repos/bethgelab/foolbox/issues/141/comments","events_url":"https://api.github.com/repos/bethgelab/foolbox/issues/141/events","html_url":"https://github.com/bethgelab/foolbox/issues/141","id":316080676,"number":141,"title":"2-class pytorch model in foolbox assertion Error","user":{"login":"rose050244","id":35261356,"avatar_url":"https://avatars1.githubusercontent.com/u/35261356?v=4","gravatar_id":"","url":"https://api.github.com/users/rose050244","html_url":"https://github.com/rose050244","followers_url":"https://api.github.com/users/rose050244/followers","following_url":"https://api.github.com/users/rose050244/following{/other_user}","gists_url":"https://api.github.com/users/rose050244/gists{/gist_id}","starred_url":"https://api.github.com/users/rose050244/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rose050244/subscriptions","organizations_url":"https://api.github.com/users/rose050244/orgs","repos_url":"https://api.github.com/users/rose050244/repos","events_url":"https://api.github.com/users/rose050244/events{/privacy}","received_events_url":"https://api.github.com/users/rose050244/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-20T00:01:13Z","updated_at":"2018-04-20T00:01:13Z","closed_at":null,"author_association":"NONE","body":"I use a trained pytorch model-resnet18 in foolbox. The model is trained to classify only 2 classes, and first loaded in python. But when I use it to make adversarial examples, it reported assertion Error. I think there are two possibilities: 1. data transformation 2. foolbox cannot generate adversarial examples for a model with only 2 classes. But I'm not sure. Is there anybody who know the answer?\r\nthe code is as follows:\r\n\r\n    pmodel.eval()\r\n    fmodel = foolbox.models.PyTorchModel(pmodel, bounds = (0, 255), num_classes = 2)\r\n    attack = foolbox.attacks.FGSM(fmodel)\r\n\r\n    transform = transforms.Compose([\r\n           transforms.RandomResizedCrop(224),\r\n           transforms.RandomHorizontalFlip(),\r\n           transforms.ToTensor()\r\n       ])\r\n    img=Image.open(\"/home/xxx/n04254777/ILSVRC2012_val_00049561.JPEG\")\r\n    transformed_img = transform(img)\r\n    input_img = transformed_img.numpy()\r\n    label = 1\r\n    adversarial = attack(input_img, label)\r\n\r\nthe reported error:\r\n  File \"/home/qingli.guo/anaconda3/lib/python3.6/site-packages/foolbox/models/pytorch.py\", line 70, in batch_predictions\r\n    assert predictions.shape == (n, self.num_classes())\r\nAssertionError\r\n\r\n"}}
{"actor":{"display_login":"rose050244"}}