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

how to train with 100% label? #15

Closed
gehaoran-dev opened this issue Aug 31, 2021 · 2 comments
Closed

how to train with 100% label? #15

gehaoran-dev opened this issue Aug 31, 2021 · 2 comments

Comments

@gehaoran-dev
Copy link

Hi @Na-Z,thanks for sharing this great work.
how to train with 100% label?
When I set labeled_ratio_list to [1. 0] for training,valueerror: num samples should be a positive integer value, but got num sample = 0.Then I set “shuffle” in dateloader to false, an error is still reported. I hope to get your suggestions

@Na-Z
Copy link
Owner

Na-Z commented Sep 1, 2021

Hi @gehaoran-dev,

If you would like to train with 100% labels, you just need to remove those parts related to UNLABELED_DATASET in train_sess.py .

For example:

  1. Do not create UNLABELED_DATASET in train_sess.py .
  2. Modify

    sess/train_sess.py

    Lines 241 to 251 in f1bbb44

    unlabeled_dataloader_iterator = iter(UNLABELED_DATALOADER)
    for batch_idx, batch_data_label in enumerate(LABELED_DATALOADER):
    try:
    batch_data_unlabeled = next(unlabeled_dataloader_iterator)
    except StopIteration:
    unlabeled_dataloader_iterator = iter(UNLABELED_DATALOADER)
    batch_data_unlabeled = next(unlabeled_dataloader_iterator)
    for key in batch_data_unlabeled:
    batch_data_label[key] = torch.cat((batch_data_label[key], batch_data_unlabeled[key]), dim=0)
    as for batch_idx, batch_data_label in enumerate(LABELED_DATALOADER):, since we only iterate over labeled dataset.

Hope this solves your problem.

@gehaoran-dev
Copy link
Author

Thank you for the quick reply~

@Na-Z Na-Z closed this as completed Oct 2, 2021
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