-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend mc-dropout to vgg and wideresnet
- Loading branch information
1 parent
df636a3
commit 73f81f3
Showing
8 changed files
with
159 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from torch_uncertainty.models.resnet.std import resnet34 | ||
from torch_uncertainty.models.utils import enable_dropout | ||
from torch_uncertainty.models.vgg.std import vgg11 | ||
from torch_uncertainty.models.wideresnet.std import wideresnet28x10 | ||
|
||
|
||
class TestMonteCarloDropout: | ||
"""Testing the ResNet std class.""" | ||
|
||
def test_resnet(self): | ||
resnet34(1, 10, 0.5, num_estimators=10) | ||
|
||
model = resnet34(1, 10, 1) | ||
model.eval() | ||
|
||
enable_dropout(model) | ||
|
||
for m in model.modules(): | ||
if m.__class__.__name__.startswith("Dropout"): | ||
assert m.training | ||
|
||
def test_vgg(self): | ||
vgg11(1, 10, dropout=0.5, num_estimators=10) | ||
|
||
model = vgg11(1, 10, dropout=0.5, num_estimators=10) | ||
model.eval() | ||
|
||
enable_dropout(model) | ||
|
||
for m in model.modules(): | ||
if m.__class__.__name__.startswith("Dropout"): | ||
assert m.training | ||
|
||
def test_wideresnet(self): | ||
wideresnet28x10(1, 10, dropout_rate=0.5, num_estimators=10) | ||
|
||
model = wideresnet28x10(1, 10, dropout_rate=0.5, num_estimators=10) | ||
model.eval() | ||
|
||
enable_dropout(model) | ||
|
||
for m in model.modules(): | ||
if m.__class__.__name__.startswith("Dropout"): | ||
assert m.training |
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
Oops, something went wrong.