{"action":"created","issue":{"url":"https://api.github.com/repos/wangyirui/AD_Prediction/issues/2","repository_url":"https://api.github.com/repos/wangyirui/AD_Prediction","labels_url":"https://api.github.com/repos/wangyirui/AD_Prediction/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/wangyirui/AD_Prediction/issues/2/comments","events_url":"https://api.github.com/repos/wangyirui/AD_Prediction/issues/2/events","html_url":"https://github.com/wangyirui/AD_Prediction/issues/2","id":315794201,"number":2,"title":"Too many dimension issue","user":{"login":"Mrinal18","id":17683007,"avatar_url":"https://avatars0.githubusercontent.com/u/17683007?v=4","gravatar_id":"","url":"https://api.github.com/users/Mrinal18","html_url":"https://github.com/Mrinal18","followers_url":"https://api.github.com/users/Mrinal18/followers","following_url":"https://api.github.com/users/Mrinal18/following{/other_user}","gists_url":"https://api.github.com/users/Mrinal18/gists{/gist_id}","starred_url":"https://api.github.com/users/Mrinal18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mrinal18/subscriptions","organizations_url":"https://api.github.com/users/Mrinal18/orgs","repos_url":"https://api.github.com/users/Mrinal18/repos","events_url":"https://api.github.com/users/Mrinal18/events{/privacy}","received_events_url":"https://api.github.com/users/Mrinal18/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-04-19T09:19:38Z","updated_at":"2018-04-22T20:40:29Z","closed_at":null,"author_association":"NONE","body":"Hey i am running your code and getting this error\r\n\r\n`2018-04-19 14:45:49 INFO: At 0-th epoch.\r\nTraceback (most recent call last):\r\n  File \"main_alextnet.py\", line 234, in <module>\r\n    main(options)\r\n  File \"main_alextnet.py\", line 133, in main\r\n    train_loss, correct_cnt = train(model, train_loader, use_cuda, criterion, optimizer, train_loss_f)\r\n  File \"main_alextnet.py\", line 158, in train\r\n    for it, train_data in enumerate(train_loader):\r\n  File \"/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py\", line 281, in __next__\r\n    return self._process_next_batch(batch)\r\n  File \"/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py\", line 301, in _process_next_batch\r\n    raise batch.exc_type(batch.exc_msg)\r\nValueError: Traceback (most recent call last):\r\n  File \"/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/torch/utils/data/dataloader.py\", line 55, in _worker_loop\r\n    samples = collate_fn([dataset[i] for i in batch_indices])\r\n  File \"/Users/science/Desktop/Alziehmer/AD_Prediction/AD_2DRandomSlicesData.py\", line 60, in __getitem__\r\n    image2D = Image.fromarray(image2D.astype(np.uint8), 'RGB')\r\n  File \"/Users/science/Desktop/Alziehmer/my_project/lib/python2.7/site-packages/PIL/Image.py\", line 2441, in fromarray\r\n    raise ValueError(\"Too many dimensions: %d > %d.\" % (ndim, ndmax))\r\nValueError: Too many dimensions: 4 > 3.`\r\n\r\n\r\n\r\nCan you help me in solving this problem?"},"comment":{"url":"https://api.github.com/repos/wangyirui/AD_Prediction/issues/comments/383410622","html_url":"https://github.com/wangyirui/AD_Prediction/issues/2#issuecomment-383410622","issue_url":"https://api.github.com/repos/wangyirui/AD_Prediction/issues/2","id":383410622,"user":{"login":"wangyirui","id":22140518,"avatar_url":"https://avatars3.githubusercontent.com/u/22140518?v=4","gravatar_id":"","url":"https://api.github.com/users/wangyirui","html_url":"https://github.com/wangyirui","followers_url":"https://api.github.com/users/wangyirui/followers","following_url":"https://api.github.com/users/wangyirui/following{/other_user}","gists_url":"https://api.github.com/users/wangyirui/gists{/gist_id}","starred_url":"https://api.github.com/users/wangyirui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangyirui/subscriptions","organizations_url":"https://api.github.com/users/wangyirui/orgs","repos_url":"https://api.github.com/users/wangyirui/repos","events_url":"https://api.github.com/users/wangyirui/events{/privacy}","received_events_url":"https://api.github.com/users/wangyirui/received_events","type":"User","site_admin":false},"created_at":"2018-04-22T20:40:29Z","updated_at":"2018-04-22T20:40:29Z","author_association":"OWNER","body":"@Mrinal18 Sorry for the confusion. I reviewed my code, and it seems your problem comes from line 39 in custom_transpose:\r\n `img = torch.from_numpy(pic.transpose((2, 0, 1)))\r\n`\r\nI suggest you to check the image shape (use print before this line) to understand what's shape the images have before sending into the function from_numpy. We did transpose here since we want to make our input sarisfy the PyTorch to_tensor API. \r\n\r\nSo I think you should do the following this to see whether you can find the mismatch:\r\n1. as I said, check the image shape before line 39 (by using print or other debug skills)\r\n2. read [http://pytorch.org/docs/master/torchvision/transforms.html#conversion-transforms](PyTorch Document) to see what shape the method ToTensor expects.\r\n"}}
{"actor":{"display_login":"wangyirui"}}