# HG changeset patch # User Xavier Glorot # Date 1257801129 18000 # Node ID bd7d540db70d990a03b1961875c5a6baa0ccd226 # Parent 0cfbaf0c598d213dffde9ee4caef61c3504eabde sum change to mean for logistic regression cost over mini-batches for LogReg2 diff -r 0cfbaf0c598d -r bd7d540db70d pylearn/algorithms/logistic_regression.py --- a/pylearn/algorithms/logistic_regression.py Mon Nov 09 15:57:00 2009 -0500 +++ b/pylearn/algorithms/logistic_regression.py Mon Nov 09 16:12:09 2009 -0500 @@ -245,12 +245,12 @@ output = nnet.sigmoid(T.dot(self.x, self.w) + self.b) xent = -self.targ * T.log(output) - (1.0 - self.targ) * T.log(1.0 - output) - sum_xent = T.sum(xent) + mean_xent = T.mean(xent) self.output = output self.xent = xent - self.sum_xent = sum_xent - self.cost = sum_xent + self.mean_xent = mean_xent + self.cost = mean_xent #define the apply method self.pred = (T.dot(self.input, self.w) + self.b) > 0.0 @@ -258,8 +258,8 @@ #if this module has any internal parameters, define an update function for them if self.params: - gparams = T.grad(sum_xent, self.params) - self.update = module.Method([self.input, self.targ], sum_xent, + gparams = T.grad(mean_xent, self.params) + self.update = module.Method([self.input, self.targ], mean_xent, updates = dict((p, p - self.lr * g) for p, g in zip(self.params, gparams)))