AD_Prediction icon indicating copy to clipboard operation
AD_Prediction copied to clipboard

Subscriptable Error

Open czainab opened this issue 6 years ago • 12 comments

F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D>python main_alextnet.py 2018-05-05 16:00:35 INFO: At 0-th epoch. Traceback (most recent call last): File "main_alextnet.py", line 236, in main(options) File "main_alextnet.py", line 135, in main train_loss, correct_cnt = train(model, train_loader, use_cuda, criterion, optimizer, train_loss_f) File "main_alextnet.py", line 160, in train for it, train_data in enumerate(train_loader): File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 281, in next return self._process_next_batch(batch) File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 301, in _process_next_batch raise batch.exc_type(batch.exc_msg) TypeError: Traceback (most recent call last): File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 55, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "C:\Users\Hashim\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 55, in samples = collate_fn([dataset[i] for i in batch_indices]) File "F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D\AD_2DRandomSlicesData.py", line 56, in getitem AXimageList = axRandomSlice(image) File "F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D\AD_2DRandomSlicesData.py", line 94, in axRandomSlice return getRandomSlice(image_array, NON_AX, AX_F, AX_SCETION) File "F:\VAIO\Latest\AD_Prediction-master\AD_Prediction-master\2D\AD_2DRandomSlicesData.py", line 73, in getRandomSlice first_p = list(mean_array).index(filter(lambda x: x>0, mean_array)[0]) TypeError: 'filter' object is not subscriptable I just ran your code with your dataset but I get this type error and unable to figure it out. Kindly help me resolving this error

czainab avatar May 05 '18 11:05 czainab

Hello @czainab, can you kindly mail me the dataset too?

mrinal18 avatar May 05 '18 13:05 mrinal18

if you are running it in python3, then filter doesnt return list but an iterable filter object.

So use list before filter and it should work first_p = list(mean_array).index(list(filter(lambda x: x>0, mean_array)[0]))

mrinal18 avatar May 05 '18 13:05 mrinal18

Well I downloaded the images in test, train text file from ADNI website. You can just simply apply for the access. Thank you for your help but I tried the above solution and it didn't work for me now I am getting another error in the same file on slice_p = int(round(first_p + (last_p - first_p)*fraction)) and the error is TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple' Kindly help me out

czainab avatar May 05 '18 20:05 czainab

Can you please guide me how you were able to run this file because I am like getting errors on every line. I just fix one error and got another on the very next line.

czainab avatar May 05 '18 20:05 czainab

look at #1, where he explained how to run the code. Kindly tell me if it runs

mrinal18 avatar May 07 '18 08:05 mrinal18

Still getting the same error TypeError: 'filter' object is not subscriptable.

czainab avatar May 09 '18 10:05 czainab

I noticed you are running this using anaconda3 which as python 3+.

kindly try running this using python2.

mrinal18 avatar May 09 '18 10:05 mrinal18

Hey, so i took the access of the ADNI data, can you kindly guide me what to do after that? i cant seem to find the data.

mrinal18 avatar May 10 '18 10:05 mrinal18

After login go to Projects, than ADNI, than click on Download, Image Collection and under Data Collection tab you will find the images.

On Thursday, May 10, 2018 3:05 PM, Mrinal18 <[email protected]> wrote:

Hey, so i took the access of the ADNI data, can you kindly guide me what to do after that? i cant seem to find the data.— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

czainab avatar May 11 '18 07:05 czainab

@czainab , replace it with this

first_p = list(mean_array).index(list(filter(lambda x: x>0, mean_array))[0])

mrinal18 avatar May 14 '18 14:05 mrinal18

@czainab , replace it with this

first_p = list(mean_array).index(list(filter(lambda x: x>0, mean_array))[0])

Did this code worked . Please let me know thank yoy

FaRe3 avatar Sep 20 '20 10:09 FaRe3

Still getting the same error TypeError: 'filter' object is not subscriptable.

please tell me how to solve this issue, if you have resolved it

coderHelloWorld avatar Nov 22 '21 20:11 coderHelloWorld