Mercurial > pylearn
changeset 1348:c8c30c675a4f
mcRBM - fixed error in normalization of quadratic term
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Thu, 21 Oct 2010 11:43:36 -0400 |
parents | 9e898b2b98e0 |
children | 0d55f8f0aedc |
files | pylearn/algorithms/mcRBM.py |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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):