Mercurial > pylearn
view embeddings/one-per-line.py @ 528:cfe3f62a08cb
bugfix, outputs needed to be in a list in the past, not anymore.
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 17 Nov 2008 13:17:00 -0500 |
parents | a07948f780b9 |
children |
line wrap: on
line source
#!/usr/bin/python import string #import psyco weightsfile = "lm-weights.txt" vocabfile = "words.asc" size = 30000 dimensions = 50 import numpy, math import sys from common.str import percent word_to_vector = {} f = open(weightsfile) f.readline() vals = [float(v) for v in string.split(f.readline())] assert len(vals) == size * dimensions vals.reverse() #for i in range(size): r = range(size) r.reverse() for i in r: l = vals[dimensions*i:dimensions*(i+1)] print string.join([`s` for s in l], "\t")