I tried to run this code in Google Colab and it worked fine. If I run it on my home computer or connect Google Colab with my local computer it gives me Errors:
EOFError: Ran out of input AttributeError: Can't pickle local object 'main.<locals>.<lambda>'
They appear because of this function:
test_loader = data.Dataloader(#Some unimportant parameters collate_fn=lambda x: data_processing(x, 'valid'))
in
for i, _data in enumerate(test_loader):
I know that I cannot pickle lambda functions but it really works in Google Colab. But I need to run it on my local computer due to time and computing power reasons.
I tried it in PyCharm and JupyterNotebook as well as in Colab with local computer (via Jupyter) but none of them worked. The Error is also not because of the import versions, I tried also newer version, which worked in Google Colab.
Advertisement
Answer
For anyone else looking for a solution for this problem: The function should not be:
collate_fn=lambda x: data_processing(x, 'valid'))
it should be
collate_fn=data_processing
(Without parentheses and parameters; the “valid” parameter was redundant)