forked from AntixK/PyTorch-VAE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
text_vamp.py
32 lines (23 loc) · 844 Bytes
/
text_vamp.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
import torch
import unittest
from models import VampVAE
from torchsummary import summary
class TestVVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = VampVAE(3, latent_dim=10).cuda()
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
# print(summary(self.model2, (3, 64, 64), device='cpu'))
def test_forward(self):
x = torch.randn(16, 3, 64, 64)
y = self.model(x)
print("Model Output size:", y[0].size())
# print("Model2 Output size:", self.model2(x)[0].size())
def test_loss(self):
x = torch.randn(144, 3, 64, 64).cuda()
result = self.model(x)
loss = self.model.loss_function(*result, M_N = 0.005)
print(loss)
if __name__ == '__main__':
unittest.main()