{"action":"closed","issue":{"url":"https://api.github.com/repos/dnouri/skorch/issues/137","repository_url":"https://api.github.com/repos/dnouri/skorch","labels_url":"https://api.github.com/repos/dnouri/skorch/issues/137/labels{/name}","comments_url":"https://api.github.com/repos/dnouri/skorch/issues/137/comments","events_url":"https://api.github.com/repos/dnouri/skorch/issues/137/events","html_url":"https://github.com/dnouri/skorch/issues/137","id":285114798,"number":137,"title":"Compatibility with BCEWithLogitsLoss","user":{"login":"zifeo","id":9053709,"avatar_url":"https://avatars1.githubusercontent.com/u/9053709?v=4","gravatar_id":"","url":"https://api.github.com/users/zifeo","html_url":"https://github.com/zifeo","followers_url":"https://api.github.com/users/zifeo/followers","following_url":"https://api.github.com/users/zifeo/following{/other_user}","gists_url":"https://api.github.com/users/zifeo/gists{/gist_id}","starred_url":"https://api.github.com/users/zifeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zifeo/subscriptions","organizations_url":"https://api.github.com/users/zifeo/orgs","repos_url":"https://api.github.com/users/zifeo/repos","events_url":"https://api.github.com/users/zifeo/events{/privacy}","received_events_url":"https://api.github.com/users/zifeo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-12-29T15:55:10Z","updated_at":"2018-05-04T13:45:34Z","closed_at":"2018-05-04T13:45:34Z","author_association":"NONE","body":"`BCEWithLogitsLoss` expects a target of size = n, 1. However the underlying tensor seems to be squeezed somewhere.\r\n\r\n```python\r\nimport numpy as np\r\nfrom sklearn.datasets import make_classification\r\nfrom torch import nn\r\n\r\nfrom skorch.net import NeuralNetClassifier\r\n\r\n\r\nX, y = make_classification(1000, 20, n_classes=2, n_informative=10, random_state=0)\r\nX = X.astype(np.float32)\r\ny = y.astype(np.float32).reshape(-1, 1)\r\n\r\nclass Dummy(nn.Module):\r\n    def __init__(self):\r\n        super().__init__()\r\n        self.dense = nn.Linear(20, 1)\r\n    \r\n    def forward(self, X):\r\n        return self.dense(X)\r\n    \r\nnet = NeuralNetClassifier(\r\n    Dummy,\r\n    criterion=nn.BCEWithLogitsLoss,\r\n)\r\n\r\nnet.fit(X, y) \r\n# ValueError: Target size (torch.Size([128])) must be the same as input size (torch.Size([128, 1]))\r\n```"}}
{"actor":{"display_login":"ottonemo"}}