blob: 23c9485e988a257688c0ec1861603558b24a3d5c (
plain)
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
|
#!/usr/bin/env python
import os, sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--model', nargs='+', required=True,
help="Models to average")
parser.add_argument('-o', '--output', required=True,
help="Output path")
args = parser.parse_args()
import numpy as np;
average = dict()
n = len(args.models)
for filename in args.models:
print "Loading", filename
with open(filename, "rb") as mfile:
m = np.load(mfile)
for k in m:
if k != "history_errs":
if k not in average:
average[k] = m[k] / n
elif average[k].shape == m[k].shape:
average[k] += m[k] / n
print "Saving to", args.output
np.savez(args.output, **average)
|