{"action":"created","issue":{"url":"https://api.github.com/repos/vlfeat/matconvnet/issues/201","labels_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/201/labels{/name}","comments_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/201/comments","events_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/201/events","html_url":"https://github.com/vlfeat/matconvnet/issues/201","id":95467522,"number":201,"title":"vl_nnsoftmaxloss bug?","user":{"login":"okvol","id":13367977,"avatar_url":"https://avatars.githubusercontent.com/u/13367977?v=3","gravatar_id":"","url":"https://api.github.com/users/okvol","html_url":"https://github.com/okvol","followers_url":"https://api.github.com/users/okvol/followers","following_url":"https://api.github.com/users/okvol/following{/other_user}","gists_url":"https://api.github.com/users/okvol/gists{/gist_id}","starred_url":"https://api.github.com/users/okvol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okvol/subscriptions","organizations_url":"https://api.github.com/users/okvol/orgs","repos_url":"https://api.github.com/users/okvol/repos","events_url":"https://api.github.com/users/okvol/events{/privacy}","received_events_url":"https://api.github.com/users/okvol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-07-16T16:03:20Z","updated_at":"2015-08-19T01:28:55Z","closed_at":null,"body":"Error message received when using GPU:\r\nError using gpuArray/subsasgn\r\nWhen assigning into a GPUArray, the subscripts must contain unique values. Subscript 1 contained repeated values.\r\n\r\nError in vl_nnsoftmaxloss (line 62)\r\n  Y(c_) = Y(c_) - 1;\r\n\r\nIt seems c_ has repeated elements. Is it natural?\r\nwith some version of the vl_nnsoftmaxloss I got:\r\nc_   =  88         160         286         330         528         528         613         716         871        1032  ....\r\n\r\nThe X, c, dzdy reproduced the issue can be downloaded from:\r\nhttp://filenurse.com/download/5a6e4fc6f9dff241c4d3e098b46d7f5c.html\r\n\r\nBTW,  c always have to start from 1, is it correct?\r\n\r\nThanks a lot!"},"comment":{"url":"https://api.github.com/repos/vlfeat/matconvnet/issues/comments/132410463","html_url":"https://github.com/vlfeat/matconvnet/issues/201#issuecomment-132410463","issue_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/201","id":132410463,"user":{"login":"eric-phu","id":10396605,"avatar_url":"https://avatars.githubusercontent.com/u/10396605?v=3","gravatar_id":"","url":"https://api.github.com/users/eric-phu","html_url":"https://github.com/eric-phu","followers_url":"https://api.github.com/users/eric-phu/followers","following_url":"https://api.github.com/users/eric-phu/following{/other_user}","gists_url":"https://api.github.com/users/eric-phu/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-phu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-phu/subscriptions","organizations_url":"https://api.github.com/users/eric-phu/orgs","repos_url":"https://api.github.com/users/eric-phu/repos","events_url":"https://api.github.com/users/eric-phu/events{/privacy}","received_events_url":"https://api.github.com/users/eric-phu/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T01:28:55Z","updated_at":"2015-08-19T01:28:55Z","body":"I just recall at some point I run into this problem too. The problem happens when computing the indices: \r\n```\r\nc = c - 1 ;\r\nc_ = 0:numel(c)-1 ;\r\nc_ = 1 + ...\r\n  mod(c_, sz(1)*sz(2)) + ...\r\n  (sz(1)*sz(2)) * max(c(:), 0)' + ...\r\n  (sz(1)*sz(2)*sz(3)) * floor(c_/(sz(1)*sz(2))) ;\r\n```\r\nIf ```c``` is ```single``` type, when ```(sz(1)*sz(2)*sz(3)) * floor(c_/(sz(1)*sz(2)))``` is too huge comparing to ```mod(c_, sz(1)*sz(2))```, MATLAB will suffer from accuracy issue when adding them up. This is more likely to happen when the size of input into softmax loss is huge while ```c``` is still ```single``` type. \r\n\r\nOne quick fix is casting ```c``` to ```double``` type. "}}