simclr
SimCLR
Bases: SimCLR
A class representing a SimCLR model.
Attributes:
Name | Type | Description |
---|---|---|
backbone |
Module
|
The backbone model used in the SimCLR model. |
num_ftrs |
int
|
The number of output features from the backbone model. |
out_dim |
int
|
The dimension of the output representations. |
projection_head |
SimCLRProjectionHead
|
The projection head used for projection head training. |
Source code in fmcib/ssl/modules/simclr.py
__init__(backbone, num_ftrs=32, out_dim=128)
Initialize the object with a backbone network, number of features, and output dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backbone
|
Module
|
The backbone network. |
required |
num_ftrs
|
int
|
The number of features. Default is 32. |
32
|
out_dim
|
int
|
The output dimension. Default is 128. |
128
|
Returns:
Type | Description |
---|---|
None |
Source code in fmcib/ssl/modules/simclr.py
forward(x, return_features=False)
Perform a forward pass of the neural network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
tuple
|
A tuple of input data. Each element of the tuple represents a different input. |
required |
return_features
|
bool
|
Whether to return the intermediate features. Default is False. |
False
|
Returns:
Type | Description |
---|---|
torch.Tensor or tuple: The output of the forward pass. If return_features is False, a single tensor is returned. If return_features is True, a tuple is returned consisting of the output tensor and the intermediate features. |