Open Darwin2011 opened 10 years ago
@Darwin2011 I think (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) is right. The weights gradient should be
@liulhdarks ,thanks The following code shows that the different weight update method. Could you check the following link? https://github.com/echen/restricted-boltzmann-machines/blob/master/rbm.py
@Darwin2011 https://github.com/echen/restricted-boltzmann-machines/blob/master/rbm.py doesn't use the visible layer after sampling when updating weights. You can refer to the follow ML frameworks.
INDArray wGradient = input.transpose().mmul(probHidden.getSecond()).sub( nvSamples.transpose().mmul(nhMeans));
DoubleMatrix wGradient = input.transpose().mmul(hProp1.prob) .sub(vPropn.sample.transpose().mmul(hPropn.prob));
Hope to help you!
@liulhdarks thanks for your kind help. I will follow your guide.
Best Regards
@liulhdarks @yusugomori I think the update for W , a , b should as follows: self.W += lr * (numpy.dot(self.input.T, ph_mean - numpy.dot(nv_samples.T, nh_means)) self.vbias += lr * numpy.mean(self.input - nv_samples, axis=0) self.hbias += lr * numpy.mean(ph_mean - nh_means, axis=0)
In origin python RBM.py. , self.W and self.hbias is not correct. This problem is also in C/C++ files, but the W has been fixed. If I am not right, please inform me. Thanks.
Such Issues are in your RBM different implementation. [python version] self.W += lr * (numpy.dot(self.input.T, ph_sample)
For there two versions, the weight update methods are incosistent. And Actually I think the right version should be self.W += lr * (numpy.dot(self.input.T, ph_means)
Best Regards