changeset 989:9e753ddcc320

mcRBM - cleaned up the preactivation function
author James Bergstra <bergstrj@iro.umontreal.ca>
date Tue, 24 Aug 2010 14:03:07 -0400
parents fd243cb2bf0b
children e70e74464170
files pylearn/algorithms/mcRBM.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/mcRBM.py	Tue Aug 24 14:02:29 2010 -0400
+++ b/pylearn/algorithms/mcRBM.py	Tue Aug 24 14:03:07 2010 -0400
@@ -245,12 +245,16 @@
         else:
             return shared(x, name=name)
 
-def hidden_cov_units_preactivation_given_v(rbm, v, small=1e-8):
+def hidden_cov_units_preactivation_given_v(rbm, v, small=0.5):
+    """Return argument to the sigmoid that would give mean of covariance hid units
+
+    See the math at the top of this file for what 'adjusted' means.
+
+    return b - 0.5 * dot(adjusted(v), U)**2
+    """
     (U,W,a,b,c) = rbm
-    unit_v = v / (TT.sqrt(TT.sum(v**2, axis=1))+small).dimshuffle(0,'x') # unit rows
-    unit_U = U  # assuming unit cols!
-    #unit_U = U / (TT.sqrt(TT.sum(U**2, axis=0))+small)  #unit cols
-    return b - 0.5 * dot(unit_v, unit_U)**2
+    unit_v = v / (TT.sqrt(TT.mean(v**2, axis=1)+small)).dimshuffle(0,'x') # adjust row norm
+    return b - 0.5 * dot(unit_v, U)**2
 
 def free_energy_given_v(rbm, v):
     """Returns theano expression for free energy of visible vector `v` in an mcRBM