-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jizong
committed
Jul 21, 2020
1 parent
83efc97
commit f0d7cc9
Showing
14 changed files
with
353 additions
and
338 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from torch.nn import functional as F | ||
|
||
|
||
class TransTwice: | ||
|
||
def __init__(self, transform) -> None: | ||
super().__init__() | ||
self._transform = transform | ||
|
||
def __call__(self, img): | ||
return [self._transform(img), self._transform(img)] | ||
|
||
|
||
def loss_fn(x, y): | ||
x = F.normalize(x, dim=-1, p=2) | ||
y = F.normalize(y, dim=-1, p=2) | ||
return 2 - 2 * (x * y).sum(dim=-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .base_epocher import EvalEpoch, SimpleFineTuneEpoch, MeanTeacherEpocher | ||
from .contrast_epocher import PretrainDecoderEpoch, PretrainEncoderEpoch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.