#!/usr/bin/env python
import numpy as np
import sys, re
from checkpointer import prefix_time_var_of_ckpt

if len(sys.argv) != 2:
    print >> sys.stderr, "usage:", sys.argv[0], " <checkpoint_file_to_dump>"
    exit(1)
ckpt_file = sys.argv[1]

file_info = prefix_time_var_of_ckpt(ckpt_file)

for n, row in enumerate(np.load(ckpt_file)):
    print "\t".join(list(file_info) + [str(n)] + map(str, row))
#!/usr/bin/env python
import numpy as np
import sys, re
from checkpointer import prefix_time_var_of_ckpt

if len(sys.argv) != 2:
    print >>sys.stderr, "usage:", sys.argv[0], " <checkpoint_file_to_dump>"
    exit(1)
ckpt_file = sys.argv[1]

file_info = prefix_time_var_of_ckpt(ckpt_file)

for n, row in enumerate(np.load(ckpt_file)):
    print "\t".join(list(file_info) + [str(n)] + map(str, row))


Пример #3
0
    raise Exception("no --files specified?")
if "," in opts.files:
    files = opts.files.split(",")
else:
    files = sorted(glob.glob(opts.files))

token_idx = TokenIdx()
token_idx.read_from_file(opts.vocab)

# map tokens to ids
ids = None
if opts.tokens:
    ids = [token_idx.id_for(t) for t in opts.tokens.split(",")]

# sanity check files are consistent with prefix and vars
prefix, _time, var = prefix_time_var_of_ckpt(files[0])
for f in files:
    next_prefix, _time, next_var = prefix_time_var_of_ckpt(f)
    if prefix != next_prefix or next_var != var:
        raise Exception("glob includes files that dont match in prefix or var")

print "\t".join("ckpt_time idx token x_l_dist x_f_dist".split())

first = None  # always compare to first
last = None   # also compare to last
for f in files:
    X = np.load(f)

    if ids:
        X = X[ids]