-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_unet.py
More file actions
33 lines (23 loc) · 803 Bytes
/
test_unet.py
File metadata and controls
33 lines (23 loc) · 803 Bytes
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
import unittest
import torch
from model import UNet, UNetConfig
class TestUNet(unittest.TestCase):
def test_shapes(self):
# Test the building and output shapes of the UNet model
config = UNetConfig(
in_channels=3,
embedding_dim=128,
encoder_channels=[32, 64, 128, 256],
encoder_down_sample=[True, True, False],
encoder_num_layers=2,
bottleneck_channels=[256, 256, 128],
bottleneck_num_layers=2,
decoder_num_layers=2
)
unet = UNet(config)
x = torch.randn(16, 3, 256, 256)
time_steps = torch.randint(0, 10, (16,))
y = unet(x, time_steps)
self.assertEquals(y.shape, (16, 3, 256, 256))
if __name__ == '__main__':
unittest.main()