nnclr
NNCLR
Bases: Module
Taken largely from https://github.com/lightly-ai/lightly/blob/master/lightly/models/nnclr.py
Source code in fmcib/ssl/modules/nnclr.py
__init__(backbone, num_ftrs=4096, proj_hidden_dim=4096, pred_hidden_dim=4096, out_dim=256, memory_bank_size=4096)
Initialize the NNCLR model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backbone
|
Module
|
The backbone neural network model. |
required |
num_ftrs
|
int
|
The number of features in the backbone output. Default is 4096. |
4096
|
proj_hidden_dim
|
int
|
The hidden dimension of the projection head. Default is 4096. |
4096
|
pred_hidden_dim
|
int
|
The hidden dimension of the prediction head. Default is 4096. |
4096
|
out_dim
|
int
|
The output dimension of the model. Default is 256. |
256
|
memory_bank_size
|
int
|
The size of the memory bank module. Default is 4096. |
4096
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in fmcib/ssl/modules/nnclr.py
forward(x, get_nearest_neighbor=True)
Forward pass of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
List[Tensor]
|
A list containing two input tensors. |
required |
get_nearest_neighbor
|
bool
|
Whether to compute and update the nearest neighbor vectors. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
Tuple[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor, torch.Tensor]]: A tuple containing two tuples. The inner tuples contain the projection and prediction vectors for each input tensor. |