-
Notifications
You must be signed in to change notification settings - Fork 164
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
1 parent
c38be08
commit 5c932ac
Showing
8 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .simclr import SimCLR | ||
from .nt_xent import NT_Xent | ||
from .nt_xent import NT_Xent | ||
from .logistic_regression import LogisticRegression |
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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
import torch.nn as nn | ||
|
||
class LogisticRegression(nn.Module): | ||
|
||
|
||
def __init__(self, n_features, n_classes): | ||
super(LogisticRegression, self).__init__() | ||
|
||
self.model = nn.Linear(n_features, n_classes) | ||
|
||
def forward(self, x): | ||
return self.model(x) |
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,9 @@ | ||
# activate pip / conda environment first | ||
|
||
# Train SimCLR model | ||
python main.py | ||
|
||
# Train linear model and run test | ||
python -m testing.logistic_regression \ | ||
with \ | ||
model_path=./logs/0 |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .masks import mask_correlated_samples | ||
from .yaml_config_hook import post_config_hook | ||
from .yaml_config_hook import post_config_hook | ||
from .filestorage import CustomFileStorageObserver |
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,9 @@ | ||
import pathlib | ||
from sacred.observers import FileStorageObserver | ||
|
||
class CustomFileStorageObserver(FileStorageObserver): | ||
def started_event(self, ex_info, command, host_info, start_time, config, meta_info, _id): | ||
if _id is None: | ||
_id = "baseline" | ||
(pathlib.Path(self.basedir) / _id).parent.mkdir(exist_ok=True, parents=True) | ||
return super().started_event(ex_info, command, host_info, start_time, config, meta_info, _id) |