Mercurial > pylearn
comparison embeddings/one-per-line.py @ 468:a07948f780b9
Moved embeddings out of sandbox
author | Joseph Turian <turian@iro.umontreal.ca> |
---|---|
date | Tue, 21 Oct 2008 16:24:44 -0400 |
parents | sandbox/embeddings/one-per-line.py@131e19dfe793 |
children |
comparison
equal
deleted
inserted
replaced
467:f3711bcc467e | 468:a07948f780b9 |
---|---|
1 #!/usr/bin/python | |
2 | |
3 import string | |
4 #import psyco | |
5 | |
6 weightsfile = "lm-weights.txt" | |
7 vocabfile = "words.asc" | |
8 size = 30000 | |
9 dimensions = 50 | |
10 | |
11 import numpy, math | |
12 import sys | |
13 from common.str import percent | |
14 | |
15 word_to_vector = {} | |
16 | |
17 f = open(weightsfile) | |
18 f.readline() | |
19 vals = [float(v) for v in string.split(f.readline())] | |
20 assert len(vals) == size * dimensions | |
21 vals.reverse() | |
22 #for i in range(size): | |
23 r = range(size) | |
24 r.reverse() | |
25 for i in r: | |
26 l = vals[dimensions*i:dimensions*(i+1)] | |
27 print string.join([`s` for s in l], "\t") |