-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
93 gpu out of memory problem during detectorfit (#95)
* Added catchall arguments to MCD fitting * Optimizing VRAM usage. * Moving models to expected device before fitting
- Loading branch information
1 parent
f541df7
commit 2cc2a9e
Showing
10 changed files
with
142 additions
and
29 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
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
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
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,40 @@ | ||
import unittest | ||
|
||
import torch | ||
|
||
from src.pytorch_ood.detector import SHE | ||
from src.pytorch_ood.model import WideResNet | ||
|
||
|
||
class TestASH(unittest.TestCase): | ||
""" | ||
Tests for activation shaping | ||
""" | ||
|
||
def setUp(self) -> None: | ||
torch.manual_seed(123) | ||
|
||
@torch.no_grad() | ||
def test_input(self): | ||
""" """ | ||
model = WideResNet(num_classes=10).eval() | ||
detector = SHE( | ||
backbone=model.features, | ||
head=model.fc, | ||
) | ||
|
||
detector.fit_features( | ||
z=torch.randn(1000, 128), | ||
y=torch.arange( | ||
1000, | ||
) | ||
% 10, | ||
batch_size=128, | ||
) | ||
|
||
x = torch.randn(size=(16, 3, 32, 32)) | ||
|
||
output = detector(x) | ||
|
||
print(output) | ||
self.assertIsNotNone(output) |