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

Add custom encoder argument to BYOL #383

Closed
Luab opened this issue Nov 19, 2020 · 1 comment
Closed

Add custom encoder argument to BYOL #383

Luab opened this issue Nov 19, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@Luab
Copy link

Luab commented Nov 19, 2020

🚀 Feature

Right now the BYOL module uses the vanilla resnet50 as encoder, although underlying SiameseArm module supports custom encoder. Passing encoder as argument to BYOL module would allow custom encoders to be used.

class BYOL(pl.LightningModule):
    def __init__(self,
                 num_classes,
                 base_encoder: Union[str, torch.nn.Module] = 'resnet50',
                 learning_rate: float = 0.2,
                 weight_decay: float = 1.5e-6,
                 input_height: int = 32,
                 batch_size: int = 32,
                 num_workers: int = 0,
                 warmup_epochs: int = 10,
                 max_epochs: int = 1000,
                 **kwargs):
        super().__init__()
        self.save_hyperparameters()

        self.online_network = SiameseArm(encoder=base_encoder)

Also small fix in SiameseArm module is needed

class SiameseArm(nn.Module):
    def __init__(self, encoder='resnet50'):
        super().__init__()

        if isinstance(encoder, str):
            encoder = torchvision_ssl_encoder(encoder)

Motivation

Adding encoder as an argument in the init method would allow seamless ablation studies by trying out different architectures.

@Luab Luab added enhancement New feature or request help wanted Extra attention is needed labels Nov 19, 2020
@github-actions
Copy link

Hi! thanks for your contribution!, great first issue!

@annikabrundyn annikabrundyn self-assigned this Nov 20, 2020
@Borda Borda added this to the v0.4 milestone Jan 18, 2021
@Borda Borda closed this as completed Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants