-
Notifications
You must be signed in to change notification settings - Fork 323
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
Revision of the MoCo SSL model #928
Revision of the MoCo SSL model #928
Conversation
@Atharva-Phatak SimCLR is a very similar method, so it makes sense to coordinate our efforts, and maybe other SSL methods too, so that we could make the interfaces as consistent as possible. We could also place both models in I think it would be important to make the models generic so that one can train
Issues #904 already suggests moving transforms to a central location. I don't know if we need separate transforms for each model. More or less identical transforms are used with both methods, and the user doesn't necessarily want to stick to the default transforms anyway. We should fix the format that the data loader should produce for contrastive learning. The format could be as similar as possible to the format that we use for classification and object detection. At least for object detection we use a tuple I added an example CLI application using LightningCLI, but IMO there's no point in trying to create a comprehensive training tool in each module. I renamed the class to MoCo. I think v2 just adds a projection head, so the same class supports both versions. |
The old way of detecting whether DDP is in use didn't work, since the DDP strategy class is now |
@senarvi Perfect, that is what my intention is essentially we add Projection heads and Losses required by SSL models. Backbones can be implemented by the user if they are custom or else imported from timm or something similar. All in all here is what I suggest
|
Hi, @senarvi, @Atharva-Phatak. I fully support @Atharva-Phatak's suggestion, if you can coordinate on that, that would be great! Btw, @senarvi, since your fork is on an organization account ( |
@otaj ok that explains it. But it's fine, I'll just keep merging master myself. |
Happy to help with this as well. Something we might want to be cautious of (if we follow this route) is the compatibility between the transforms and losses of various SSL methods. |
… downloaded automatically)
@Borda the problem was that the data module used in the unit tests provided 4-dimensional tensors of image pairs, while the default ImageNet data module provided tuples of 3-dimensional tensors and that's what the input validator expected too. Now it supports both. There was also a new unit test that checks the CLI scripts. It failed because ImageNet cannot be downloaded automatically, so I changed the CLI application to use CIFAR10 instead. If I'm correct, now all the unit tests pass. I can only see some Docker errors now. But let me know if there's still something that needs fixing. |
@senarvi the GPU start issue is fixed on master... |
@Borda merged master and now everything passes. |
|
||
from pl_bolts.datamodules import VOCDetectionDataModule | ||
|
||
LightningCLI(RetinaNet, VOCDetectionDataModule, seed_everything_default=42) | ||
cli_class(RetinaNet, VOCDetectionDataModule, seed_everything_default=42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cli_class(RetinaNet, VOCDetectionDataModule, seed_everything_default=42) | |
LightningCLI(RetinaNet, VOCDetectionDataModule, seed_everything_default=42) |
@Borda the thing that you commented on is a real PITA to get working so that mypy won't complain in any case. There's a lot of talk about this on GitHub, see for example this. The problem is that mypy doesn't consider the |
@Borda also, the exception can be either an |
@Borda should we go like this? I'm fine with anything that makes mypy happy. |
lets mypy/typing address in separate PR :) |
…-lightning-bolts into moco-revision
@Borda fine. Actually it was necessary to only support the current location (pytorch_lightning.cli) to make the tests pass. Now it's clean. |
What does this PR do?
Related to issue #839 that discusses a major revision of Bolts, this pull request refactors the Momentum Contrast (MoCo) SSL model. That issue will probably become impossible to follow if all the details are discussed there, so I'll write my suggestions below. I would be happy to hear some feedback.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃