def __init__(self, dataloader_kNN, num_classes):
    super().__init__(dataloader_kNN, num_classes)
    num_splits = (0 if sync_batchnorm else 8)
    resnet = lightly.models.ResNetGenerator('resnet-18', num_splits=num_splits)
    self.backbone = nn.Sequential(*list(resnet.children())[:(- 1)], nn.AdaptiveAvgPool2d(1))
    self.projection_head = heads.MoCoProjectionHead(512, 512, 128)
    self.backbone_momentum = copy.deepcopy(self.backbone)
    self.projection_head_momentum = copy.deepcopy(self.projection_head)
    utils.deactivate_requires_grad(self.backbone_momentum)
    utils.deactivate_requires_grad(self.projection_head_momentum)
    self.criterion = lightly.loss.NTXentLoss(temperature=0.1, memory_bank_size=4096)
def __init__(self, dataloader_kNN, num_classes):
    super().__init__(dataloader_kNN, num_classes)
    num_splits = (0 if sync_batchnorm else 8)
    resnet = lightly.models.ResNetGenerator('resnet-18', num_splits=num_splits)
    self.backbone = nn.Sequential(*list(resnet.children())[:(- 1)], nn.AdaptiveAvgPool2d(1))
    self.projection_head = heads.MoCoProjectionHead(512, 512, 128)
    self.backbone_momentum = copy.deepcopy(self.backbone)
    self.projection_head_momentum = copy.deepcopy(self.projection_head)
    utils.deactivate_requires_grad(self.backbone_momentum)
    utils.deactivate_requires_grad(self.projection_head_momentum)
    self.criterion = lightly.loss.NTXentLoss(temperature=0.1, memory_bank_size=4096)