-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
2dce68d
commit 3fd9b91
Showing
2 changed files
with
61 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from metnet.layers.StochasticDepth import StochasticDepth | ||
from metnet.layers.SqueezeExcitation import SqueezeExcite | ||
from metnet.layers.MBConv import MBConv | ||
import torch | ||
|
||
|
||
def test_stochastic_depth(): | ||
test_tensor = torch.ones(1) | ||
|
||
stochastic_depth = StochasticDepth(drop_prob=0) | ||
assert test_tensor == stochastic_depth(test_tensor) | ||
|
||
stochastic_depth = StochasticDepth(drop_prob=1) | ||
assert torch.zeros_like(test_tensor) == stochastic_depth(test_tensor) | ||
|
||
|
||
def test_squeeze_excitation(): | ||
n, c, h, w = 1, 3, 16, 16 | ||
test_tensor = torch.rand(n, c, h, w) | ||
|
||
squeeze_excite = SqueezeExcite(in_channels=c) | ||
assert test_tensor.shape == squeeze_excite(test_tensor).shape | ||
|
||
|
||
def test_mbconv(): | ||
n, c, h, w = 1, 3, 16, 16 | ||
test_tensor = torch.rand(n, c, h, w) | ||
mb_conv = MBConv(c) | ||
|
||
assert test_tensor.shape == mb_conv(test_tensor).shape |