forked from taoroalin/WNet
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtests.py
54 lines (46 loc) · 1.23 KB
/
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
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 15 20:36:27 2018
@author: tao
"""
import train
import WNet
import torch
import numpy as np
def EncoderTest(verbose=True):
shape=(2, 4, 224, 224)
encoder=WNet.UEnc(shape[1])
data=torch.rand((shape[0], 3, shape[2], shape[3]))
encoded=encoder(data)
assert tuple(encoded.shape)==shape
var=torch.var(encoded)
mean=torch.mean(encoded)
if verbose:
print('Passed Encoder Test with var=%s and mean=%s' % (var, mean))
return encoded
def DecoderTest():
shape=(2, 4, 224, 224)
out_shape=(2, 3, 224, 224)
decoder=WNet.UDec(shape[1])
data=torch.rand(tuple(shape))
decoded=decoder(data)
assert tuple(decoded.shape)==out_shape
var=torch.var(decoded)
mean=torch.mean(decoded)
print('Passed Decoder Test with var=%s and mean=%s' % (var, mean))
def WNetTest():
encoded=EncoderTest(verbose=False)
decoder=WNet.UDec(4)
reproduced=decoder(encoded)
var=torch.var(reproduced)
mean=torch.mean(reproduced)
print('Passed Decoder Test with var=%s and mean=%s' % (var, mean))
def TrainTest():
pass
def AllTest():
EncoderTest()
DecoderTest()
WNetTest()
TrainTest()
print('WNet Passed All Tests!')
AllTest()