comparison mlp_factory_approach.py @ 212:9b57ea8c767f

previous commit was supposed to concern only one file, dataset.py, try to undo my other changes with this commit (nothing was broken though, just useless debugging prints)
author Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
date Wed, 21 May 2008 17:42:20 -0400
parents bd728c83faff
children 6fa8fbb0c3f6
comparison
equal deleted inserted replaced
211:bd728c83faff 212:9b57ea8c767f
31 """Update this model from more training data.""" 31 """Update this model from more training data."""
32 params = self.params 32 params = self.params
33 #TODO: why should we have to unpack target like this? 33 #TODO: why should we have to unpack target like this?
34 for input, target in input_target: 34 for input, target in input_target:
35 rval= self.update_fn(input, target[:,0], *params) 35 rval= self.update_fn(input, target[:,0], *params)
36 print rval[0] 36 #print rval[0]
37 37
38 def __call__(self, testset, fieldnames=['output_class']): 38 def __call__(self, testset, fieldnames=['output_class']):
39 """Apply this model (as a function) to new data""" 39 """Apply this model (as a function) to new data"""
40 #TODO: cache fn between calls 40 #TODO: cache fn between calls
41 assert 'input' == testset.fieldNames()[0] 41 assert 'input' == testset.fieldNames()[0]
121 best = rval 121 best = rval
122 for stp in self.early_stopper(): 122 for stp in self.early_stopper():
123 rval.update( 123 rval.update(
124 minset.minibatches([input, target], minibatch_size=min(32, 124 minset.minibatches([input, target], minibatch_size=min(32,
125 len(trainset)))) 125 len(trainset))))
126 print 'mlp.__call__(), we did an update' 126 #print 'mlp.__call__(), we did an update'
127 if stp.set_score: 127 if stp.set_score:
128 stp.score = rval(valset, ['loss_01']) 128 stp.score = rval(valset, ['loss_01'])
129 if (stp.score < stp.best_score): 129 if (stp.score < stp.best_score):
130 best = copy.copy(rval) 130 best = copy.copy(rval)
131 rval = best 131 rval = best