a pickle's pickle
Benji York
benji at benjiyork.com
Tue Aug 2 15:13:51 EDT 2005
temposs at gmail.com wrote:
> So basically trainer always gets an existing TrainingMatrix(the class)
> pickled object if there is a file to read from, otherwise it just makes
> a new instance. Either way, the instance trainer is pickled at the end.
Right, but the data you're interested in is contained in the class, not
the instance. You need to move the mutable class attributes into the
instance. Like so:
class TrainingMatrix:
totalWordsProcessed = 0
numWords = 0
numContexts = 0
matrixWords = 0
def __init__(self):
self.matrix = []
self.estimator = {}
self.wordInfo = {}
self.contextInfo = {}
--
Benji York
More information about the Python-list
mailing list