Mercurial > pylearn
annotate cost.py @ 448:0961d4b56ec5
Added some documentation
author | Joseph Turian <turian@gmail.com> |
---|---|
date | Wed, 03 Sep 2008 17:08:54 -0400 |
parents | 45879c1ecde7 |
children | 2bb67e978c28 |
rev | line source |
---|---|
413 | 1 """ |
2 Cost functions. | |
439 | 3 |
4 @note: All of these functions return one cost per example. So it is your | |
5 job to perform a tensor.sum over the individual example losses. | |
413 | 6 """ |
7 | |
415 | 8 import theano.tensor as T |
9 | |
413 | 10 def quadratic(target, output, axis=1): |
11 return T.mean(T.sqr(target - output), axis) | |
12 | |
13 def cross_entropy(target, output, axis=1): | |
448 | 14 """ |
15 @todo: This is essentially duplicated as nnet_ops.binary_crossentropy | |
16 """ | |
434
0f366ecb11ee
log2->log in cost
Olivier Breuleux <breuleuo@iro.umontreal.ca>
parents:
415
diff
changeset
|
17 return -T.mean(target * T.log(output) + (1 - target) * T.log(1 - output), axis=axis) |