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

Chapter 6: A Journey Into Sound #54

Closed
eiler-partner opened this issue Dec 14, 2020 · 2 comments
Closed

Chapter 6: A Journey Into Sound #54

eiler-partner opened this issue Dec 14, 2020 · 2 comments

Comments

@eiler-partner
Copy link

Hi,
I do not find the solution, why len(train_loader.dataset) is 0 and leads to this error.
Thank you for help.
Brds,
Patrick

[9] train(audionet, optimizer, torch.nn.CrossEntropyLoss(), train_loader, valid_loader, epochs=20, device=device)

ZeroDivisionError Traceback (most recent call last)
in
----> 1 train(audionet, optimizer, torch.nn.CrossEntropyLoss(), train_loader, valid_loader, epochs=20, device=device)

in train(model, optimizer, loss_fn, train_loader, val_loader, epochs, device)
14 optimizer.step()
15 training_loss += loss.data.item() * inputs.size(0)
---> 16 training_loss /= len(train_loader.dataset)
17
18 model.eval()

ZeroDivisionError: float division by zero

@MarcusFra
Copy link
Contributor

I think it's due to the DataLoader object, which seems to be instantiated, but empty.

Have you set the correct path for your own environment and downloaded the data correctly in advance?

PATH_TO_ESC50 = Path.cwd() / 'esc50' # you might have to adjust this line, if your image directory is not '.../current_working_dir/esc50/'
train_esc50 = ESC50(PATH_TO_ESC50 / "train")
train_loader = torch.utils.data.DataLoader(train_esc50, batch_size = bs, shuffle = True)

@eiler-partner
Copy link
Author

Hi,
That is so funny. I was doing that:
print(PATH_TO_ESC50)
print(train_esc50)
delivers
C:\Users\patri\Deep_Learning\I_pytorch_deep_learning\chapter6\esc50\audio
<main.ESC50 object at 0x000002820FBEFC10>
I took the original file and adaped the path an now it is running.

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