Shortcuts

Note

You are reading the documentation for MMSelfSup 0.x, which will soon be deprecated by the end of 2022. We recommend you upgrade to MMSelfSup 1.0.0rc versions to enjoy fruitful new features and better performance brought by OpenMMLab 2.0. Check out the changelog, code and documentation of MMSelfSup 1.0.0rc for more details.

Source code for mmselfsup.models.utils.multi_prototypes

# Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.runner import BaseModule


[docs]class MultiPrototypes(BaseModule): """Multi-prototypes for SwAV head. Args: output_dim (int): The output dim from SwAV neck. num_prototypes (list[int]): The number of prototypes needed. """ def __init__(self, output_dim, num_prototypes): super(MultiPrototypes, self).__init__() assert isinstance(num_prototypes, list) self.num_heads = len(num_prototypes) for i, k in enumerate(num_prototypes): self.add_module('prototypes' + str(i), nn.Linear(output_dim, k, bias=False))
[docs] def forward(self, x): out = [] for i in range(self.num_heads): out.append(getattr(self, 'prototypes' + str(i))(x)) return out
Read the Docs v: 0.x
Versions
latest
stable
1.x
dev-1.x
0.x
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.