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

TypeError: 'PinMemCustomBatch' object is not subscriptable #6

Closed
modaresimr opened this issue Feb 21, 2021 · 5 comments
Closed

TypeError: 'PinMemCustomBatch' object is not subscriptable #6

modaresimr opened this issue Feb 21, 2021 · 5 comments

Comments

@modaresimr
Copy link

When i run follwing line:
sh scripts/preproc.sh
I face with this error:
Would you please help me?

Dataset dcase2020task3 is being developed......

Extracting scalar......

Traceback (most recent call last):
  File "seld/main.py", line 59, in <module>
    sys.exit(main(args, cfg))
  File "seld/main.py", line 36, in main
    preprocessor.extract_scalar()
  File "/workspace/sed/EIN-SELD/seld/learning/preprocess.py", line 148, in extract_scalar
    batch_x = batch_sample['waveform']
TypeError: 'PinMemCustomBatch' object is not subscriptable
@yinkalario
Copy link
Owner

It seems your information is not complete. There is no file connected with 'PinMemCustomBatch' in your error message. Try to re-download the code without modification. Thanks.

@modaresimr
Copy link
Author

Thanks. I have replaced the code in line 148 of preprocess.py with the following and the issue has been resolved.

batch_x = batch_sample.batch_out_dict['waveform']

@yinkalario
Copy link
Owner

Thanks. I have replaced the code in line 148 of preprocess.py with the following and the issue has been resolved.

batch_x = batch_sample.batch_out_dict['waveform']

Thanks for letting me know. But it is still a bit odd. The PinMemCustomBatch is defined in

class PinMemCustomBatch:

, where the function pin_memory returns self.batch_out_dict, which means batch_out_dict should not be seen by other functions. Are you sure you used the code without modification?

Thanks,
Yin

@modaresimr
Copy link
Author

In this case, the following line (and similar lines) should be changed to batch_sample.pin_memory() but for me the simplest way was changing it to batch_sample.batch_out_dict['waveform']

batch_x = batch_sample['waveform']

Thanks again for your support ;)

@yinkalario
Copy link
Owner

In this case, the following line (and similar lines) should be changed to batch_sample.pin_memory() but for me the simplest way was changing it to batch_sample.batch_out_dict['waveform']

batch_x = batch_sample['waveform']

Thanks again for your support ;)

I think you completely misunderstand the code. I don't know your python and pytorch environment, nor if you have changed the code.

All I can say is if you look at

pin_memory=True
, there is a pin_memory flag, which calls the pin_memory() function in PinMemCustomBatch. For more information, you can check: https://pytorch.org/docs/stable/data.html#memory-pinning

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

2 participants