changeset 413:f63dfb0ac7dc

Added cost functions
author Joseph Turian <turian@iro.umontreal.ca>
date Fri, 11 Jul 2008 15:26:41 -0400
parents 35b858a1d4fd
children 643dbccde1fc
files cost.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cost.py	Fri Jul 11 15:26:41 2008 -0400
@@ -0,0 +1,9 @@
+"""
+Cost functions.
+"""
+
+def quadratic(target, output, axis=1):
+    return T.mean(T.sqr(target - output), axis)
+
+def cross_entropy(target, output, axis=1):
+    return -T.mean(target * T.log2(output) + (1 - target) * T.log2(1 - output), axis=axis)