def __init__(self, w): '''input is either a filename or weightstr.''' if w.strip() != "" and not (w.find(":") >= 0 or w.find("=") >= 0): w = open(w).readline().strip() # single line Vector.__init__(self, w) print >> logs, 'using weights: "%s...%s" (%d fields)' \ % (w[:10], w[-10:], len(self)) self.lm_weight = self["lm"]
def __init__(self, w): '''input is either a filename or weightstr or vector .''' if not isinstance(w, Vector) and w.strip() != "" and not (w.find(":") >= 0 or w.find("=") >= 0): w = open(w).readline().strip() # single line Vector.__init__(self, w) print >> logs, 'using weights: (%d fields)' \ % (len(self)) self.lm_weight = self["lm"]
def __init__(self, d={}): Vector.__init__(self, d) self.last_update = {} self.N = 0 ## number of examples (per iter). will be reset at the end of the first iteration