diversity_loss
DiversityLoss
¶
Bases: torch.nn.Module
Encourages predictions to be uniform, batch wise. Takes logits (before softmax) as input.
For example:
-
A tensor with a large loss:
torch.tensor([[1e4, 0, 0], [1e4, 0, 0], [1e4, 0, 0]])
-
A tensor with a small loss:
torch.tensor([[1e4, 0, 0], [0, 1e4, 0], [0, 0, 1e4]])
Source code in pytorch_adapt\layers\diversity_loss.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
__init__(after_softmax=False)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after_softmax |
bool
|
If |
False
|
Source code in pytorch_adapt\layers\diversity_loss.py
19 20 21 22 23 24 25 26 |
|