GithubHelp home page GithubHelp logo

Comments (8)

sannawag avatar sannawag commented on May 20, 2024 1

Thank you @msamogh, this makes perfect sense.

from nonechucks.

msamogh avatar msamogh commented on May 20, 2024

Hi @sannawag,
Can you tell me a bit more of what you are trying to do? It would help me understand your situation better so that I can help you.

from nonechucks.

sannawag avatar sannawag commented on May 20, 2024

@msamogh, given the large size of my training dataset, I wish to validate more often than once per epoch. For this reason, when enumerating the dataloader, I check whether the index equals the length of the dataloader - 1. I do not directly have access to the dataset length because I initialize the dataloaders in a separate function.

from nonechucks.

msamogh avatar msamogh commented on May 20, 2024

So if I understand you correctly, you wish to enumerate through a single DataLoader in a nested fashion?

from nonechucks.

sannawag avatar sannawag commented on May 20, 2024

I do wish to enumerate through DataLoaders in a nested fashion, but one is a built from a training set, the other from a validation set.

from nonechucks.

msamogh avatar msamogh commented on May 20, 2024

So what's preventing you from enumerating through the validation set in the usual way (using enumerate())? You can reinitialize your validation set DataLoader inside the loop as many times you want.

from nonechucks.

sannawag avatar sannawag commented on May 20, 2024

Here is the basic structure I am trying to obtain:

for i, sample in enumerate(training_dataloader):
    # process the training sample
    if i % step == 0 or i == len(training_dataloader) - 1:
       validate_and_report_loss(validation_dataloader)

The catch is computing len(training_dataloader).

Thanks!

from nonechucks.

msamogh avatar msamogh commented on May 20, 2024

Ah, I see. The bad news is you can't call len on your DataLoader (unless you're okay with setting eager_eval to True on your dataset). The good news is, in this case, is that you can simply move the part where you check if it's the last iteration to outside the loop (once it has ended).

This is because without actually checking every element, SafeDataLoader has no way of telling what the effective number of valid samples in your dataset is going to be. So one of the things you will have to give up with SafeDataLoader is the ability to call len().

Hope that helps!

from nonechucks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.