Mercurial > pylearn
changeset 637:83397981a118
merge
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 21 Jan 2009 16:02:07 -0500 |
parents | 9fb784c1f23d (current diff) 89bc88affef0 (diff) |
children | 4b1bb5810423 af14b1f32882 |
files | |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/algorithms/cost.py Wed Jan 21 16:01:16 2009 -0500 +++ b/pylearn/algorithms/cost.py Wed Jan 21 16:02:07 2009 -0500 @@ -14,12 +14,13 @@ def quadratic(target, output, axis=1): return T.mean(T.sqr(target - output), axis=axis) -def cross_entropy(target, output, axis=1): +def cross_entropy(target, output, mean_axis=0, sum_axis=1): """ @todo: This is essentially duplicated as nnet_ops.binary_crossentropy @warning: OUTPUT and TARGET are reversed in nnet_ops.binary_crossentropy """ - return -T.mean(target * T.log(output) + (1 - target) * T.log(1 - output), axis=axis) + XE = target * T.log(output) + (1 - target) * T.log(1 - output) + return -T.mean(T.sum(XE, axis=sum_axis),axis=mean_axis) def KL_divergence(target, output): """