Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptable Error #7

Open
czainab opened this issue May 5, 2018 · 12 comments
Open

Subscriptable Error #7

czainab opened this issue May 5, 2018 · 12 comments

Comments

@czainab
Copy link

czainab commented May 5, 2018

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

@mrinal18
Copy link

mrinal18 commented May 5, 2018

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

@mrinal18
Copy link

mrinal18 commented May 5, 2018

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]))

@czainab
Copy link
Author

czainab commented May 5, 2018

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
Copy link
Author

czainab commented May 5, 2018

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.

@mrinal18
Copy link

mrinal18 commented May 7, 2018

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

@czainab
Copy link
Author

czainab commented May 9, 2018

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

@mrinal18
Copy link

mrinal18 commented May 9, 2018

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

kindly try running this using python2.

@mrinal18
Copy link

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.

@czainab
Copy link
Author

czainab commented May 11, 2018 via email

@mrinal18
Copy link

@czainab , replace it with this

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

@FaRe3
Copy link

FaRe3 commented Sep 20, 2020

@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

@coderHelloWorld
Copy link

coderHelloWorld commented Nov 22, 2021

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants