-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_evaluation.py
57 lines (46 loc) · 1.32 KB
/
read_evaluation.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
__author__ = 'haroun habeeb'
__mail__ = '[email protected]'
import argparse
import pickle
import os
import sys
import pdb
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
from torch.distributions import Bernoulli
from torchvision import datasets, transforms
from torchvision.utils import make_grid, save_image
from utils import smooth_distribution, EPS, sample_range, \
compute_elbo_sampled_batched, glorot_init
from utils import save_checkpoint, load_checkpoint, every
from statistics import median
from visualize import make_dot, display
from dbn import DBN
torch.manual_seed(1337)
MODELS_DIR = 'models/'
filename = 'models/1.28.2018.data_losses.pickle'
def avg(ls):
return sum(ls) / len(ls)
if __name__ == '__main__':
if len(sys.argv) > 1:
filename = sys.argv[1]
with open(filename, 'rb') as f:
losses = pickle.load(f)
vll = losses['vanilla']
gll = losses['greedy']
rll = losses['random']
vl = [t[0].data[0] for t in vll]
gl = [t[0].data[0] for t in gll]
rl = [median([ti.data[0] for ti in t]) for t in rll]
v = avg(vl)
g = avg(gl)
r = avg(rl)
print('vanilla:', v)
print('greedy:', g)
print('random:', r)