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

Questions about _train_epoch in trainer.py #11

Closed
ciuzaak opened this issue May 29, 2021 · 4 comments
Closed

Questions about _train_epoch in trainer.py #11

ciuzaak opened this issue May 29, 2021 · 4 comments

Comments

@ciuzaak
Copy link

ciuzaak commented May 29, 2021

if self.mode == 'supervised':
# dataloader = iter(self.supervised_loader)
# tbar = tqdm(range(len(self.supervised_loader)), ncols=135)
dataloader = iter(cycle(self.supervised_loader))
tbar = tqdm(range(self.iter_per_epoch), ncols=135)
else:
dataloader = iter(zip(cycle(self.supervised_loader), cycle(self.unsupervised_loader)))
tbar = tqdm(range(self.iter_per_epoch), ncols=135)

The comment part is your original code.
In the semi-supervised method, 'cycle' was used to expand the number of iterations of labeled images. Obviously the number of iterations in the fully-supervised is much less. I think this comparison may be unfair. What is your opinion or modification plan? Looking forward to your answer, thanks!

@X-Lai
Copy link
Collaborator

X-Lai commented May 29, 2021

Thank you for raising this question.

Yes, you are correct at first. Looks like the epoch size is len(self.supervised_loader) rather than self.iter_per_epoch, i.e., 1157 (we fix self.iter_per_epoch to 1157 in this line) in the fully-supervised setting.

However, in the fully-supervised, len(self.supervised_loader) is actually a little larger than 1157. So, in fact, the number of training iterations in the fully-supervised setting should be a little larger. Even with fewer training steps, our model can achieve better performance, so I think it is considerably fair to make such comparison.

@ciuzaak
Copy link
Author

ciuzaak commented May 29, 2021

Thanks for your answer.
I understand that while using all 10582 images in VOC dataset, len(self.supervised_loader) is larger than 1157.
Maybe what I described was not clear enough. I mainly want to know how to compare with SupOnly method. For example, with 300 labeled images, len(self.supervised_loader) is still less than your fixed iterations.

@X-Lai
Copy link
Collaborator

X-Lai commented May 30, 2021

I guess you may misunderstand the config for SupOnly method.

You should note that for SupOnly method, the mode should still be 'semi' rather than 'supervised', so the epoch size is still self.iter_per_epoch. In this case, only the labeled data is used to compute the cross entropy loss, and the unlabeled data is simple discarded. Therefore, the comparison is absolutely fair.

@ciuzaak
Copy link
Author

ciuzaak commented May 30, 2021

Ok I got it. Thank you very much!

@ciuzaak ciuzaak closed this as completed May 30, 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