mcd_loss
MCDLoss
¶
Bases: torch.nn.Module
Implementation of the loss function used in Maximum Classifier Discrepancy for Unsupervised Domain Adaptation.
Source code in pytorch_adapt\layers\mcd_loss.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
__init__(dist_fn=None)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dist_fn |
Callable[[torch.Tensor], torch.Tensor]
|
Computes the mean distance between two softmaxed tensors.
If |
None
|
Source code in pytorch_adapt\layers\mcd_loss.py
19 20 21 22 23 24 25 26 |
|
forward(x, y)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
torch.Tensor
|
a batch of class logits |
required |
y |
torch.Tensor
|
the other batch of class logits |
required |
Returns:
Type | Description |
---|---|
torch.Tensor
|
The discrepancy between the two batches of class logits. |
Source code in pytorch_adapt\layers\mcd_loss.py
28 29 30 31 32 33 34 35 36 |
|