changeset 975:38e66e0da66a

mcRBM - put softplus in directly for num. stability
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 23 Aug 2010 16:02:34 -0400
parents f2cdcc71ece1
children 4cbd65cf902d
files pylearn/algorithms/mcRBM.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/mcRBM.py	Mon Aug 23 16:02:02 2010 -0400
+++ b/pylearn/algorithms/mcRBM.py	Mon Aug 23 16:02:34 2010 -0400
@@ -194,9 +194,9 @@
     """
     U, W, a, b, c = rbm
 
-    t0 = -TT.sum(TT.log1p(TT.exp(hidden_cov_units_preactivation_given_v(rbm, v))),axis=1)
-    t1 = -TT.sum(TT.log1p(TT.exp(c + dot(v,W))), axis=1)
-    t2 = 0.5 * TT.sum(v**2, axis=1)
+    t0 = -TT.sum(TT.nnet.softplus(hidden_cov_units_preactivation_given_v(rbm, v)),axis=1)
+    t1 = -TT.sum(TT.nnet.softplus(c + dot(v,W)), axis=1)
+    t2 =  0.5 * TT.sum(v**2, axis=1)
     t3 = -TT.dot(v, a)
     return t0 + t1 + t2 + t3