# HG changeset patch # User boulanni # Date 1284521099 14400 # Node ID be53f56b37b82ba3ba57291cbf538ffae266d69c # Parent 1f546562239484740dea35cd606b15a34027521a Added example cost formula with tags and created a formulas page in the doc diff -r 1f5465622394 -r be53f56b37b8 doc/formulas.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/formulas.txt Tue Sep 14 23:24:59 2010 -0400 @@ -0,0 +1,14 @@ + +.. contents:: Formulas categories + +pylearn.formulas.costs +----------------------- +.. automodule:: pylearn.formulas.costs + :members: + +pylearn.formulas.noise +----------------------- +.. automodule:: pylearn.formulas.noise + :members: + + diff -r 1f5465622394 -r be53f56b37b8 doc/index.txt --- a/doc/index.txt Tue Sep 14 23:14:00 2010 -0400 +++ b/doc/index.txt Tue Sep 14 23:24:59 2010 -0400 @@ -24,6 +24,7 @@ For the moment, the following documentation is available. +* `Formulas `_ -- Built-in math formulas optimized for speed and robustness * :doc:`io.SeriesTables module ` -- Saves error series and other statistics during training * `API `_ -- The automatically-generated API documentation diff -r 1f5465622394 -r be53f56b37b8 pylearn/formulas/costs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylearn/formulas/costs.py Tue Sep 14 23:24:59 2010 -0400 @@ -0,0 +1,22 @@ +""" +This script defines a few often used cost functions. +""" +import theano +import theano.tensor as T +from tags import tags + +@tags('cost','binary','cross-entropy') +def binary_crossentropy(output, target): + """ Compute the crossentropy of binary output wrt binary target. + + .. math:: + L_{CE} \equiv t\log(o) + (1-t)\log(1-o) + + :type output: Theano variable + :param output: Binary output or prediction :math:`\in[0,1]` + :type target: Theano variable + :param target: Binary target usually :math:`\in\{0,1\}` + """ + return -(target * tensor.log(output) + (1.0 - target) * tensor.log(1.0 - output)) + + diff -r 1f5465622394 -r be53f56b37b8 pylearn/formulas/noise.py --- a/pylearn/formulas/noise.py Tue Sep 14 23:14:00 2010 -0400 +++ b/pylearn/formulas/noise.py Tue Sep 14 23:24:59 2010 -0400 @@ -1,14 +1,13 @@ """ -This script define the different symbolic noise functions -The noise contract is simple: noise_lvl is a symbolic variable going from 0 to 1 +This script define the different symbolic noise functions. +The noise contract is simple: noise_lvl is a symbolic variable going from 0 to 1. 0: no changement. 1: max noise. - """ import theano import theano.tensor as T -import tags +from tags import tags s=""" * A latex mathematical description of the formulas(for picture representation in generated documentation) * Tags(for searching):