-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_tests.py
65 lines (46 loc) · 1.84 KB
/
model_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import unittest
from model import *
import torch
class TestModel(unittest.TestCase):
def test_same_size_0_mod_16(self):
tensor = torch.randn((3, 1, 160, 160))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
def test_same_size_1_mod_16(self):
tensor = torch.randn((3, 1, 161, 161))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
def test_same_size_15_mod_16(self):
tensor = torch.randn((3, 1, 159, 159))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
def test_same_size_8_mod_16(self):
tensor = torch.randn((3, 1, 152, 152))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
def test_diff_size_1(self):
tensor = torch.randn((3, 1, 152, 160))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
def test_diff_size_2(self):
tensor = torch.randn((3, 1, 172, 160))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
def test_diff_size_3(self):
tensor = torch.randn((3, 1, 157, 160))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
def test_diff_size_4(self):
tensor = torch.randn((3, 1, 157, 149))
model = UNET(in_channels=1, out_channels=1)
preds = model(tensor)
self.assertEqual(preds.shape, tensor.shape)
if __name__ == '__main__':
unittest.main()