# HG changeset patch # User James Bergstra # Date 1287675816 14400 # Node ID c8c30c675a4f5d64e3b664de5073674e91dda068 # Parent 9e898b2b98e0d06a2e9d6e7d14d00b7d30e8310c mcRBM - fixed error in normalization of quadratic term diff -r 9e898b2b98e0 -r c8c30c675a4f pylearn/algorithms/mcRBM.py --- a/pylearn/algorithms/mcRBM.py Thu Oct 21 11:42:36 2010 -0400 +++ b/pylearn/algorithms/mcRBM.py Thu Oct 21 11:43:36 2010 -0400 @@ -547,18 +547,21 @@ - c - the mean bias (theano shared variable) """ - def __init__(self, U, W, a, b, c, P): + # PCA eigenvectors (E) [scaled by 1/sqrt(eigenvals)] has to be passed to model + # because v has to be divided by the number original dimensions + # not the number of pca dimensions in hidden_cov_units_preactivation_given_v() + def __init__(self, U, W, a, b, c, P, norm_doctoring): self.P = P + self.norm_doctoring = norm_doctoring super(mcRBM_withP, self).__init__(U,W,a,b,c) - def hidden_cov_units_preactivation_given_v(self, v, small=0.5): + def hidden_cov_units_preactivation_given_v(self, v): """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 """ - unit_v = v / (TT.sqrt(TT.mean(v**2, axis=1)+small)).dimshuffle(0,'x') # adjust row norm + slope, offset = self.norm_doctoring + norm_sq = TT.sum(v**2, axis=1) * slope + offset + unit_v = v / TT.sqrt(norm_sq).dimshuffle(0,'x') # adjust row norm return self.b + 0.5 * dot(dot(unit_v, self.U)**2, self.P) def n_hidden_cov_units(self):