5

Context:

I am implementing Gaussian Bernoulli RBM, it is like the popular RBM but with real-valued visible units.

True that the procedure of sampling hidden values p(h=1|v) are the same for both, i.e.

enter image description here

Problem:

My problem is in coding (using Python) p(v|h), which is,

enter image description here

I am a little bit confused as to how N() works. Do I simply add Gaussian noise using the data's standard deviation to b + sigma * W.dot(h)?

Thank you in advance.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
IssamLaradji
  • 6,637
  • 8
  • 43
  • 68
  • 3
    in terms of `scipy`'s methods, that equation is simply `v = stats.norm.rvs( loc=b + sigma * W.dot(h), scale=sigma )`, not sure what is ambiguous here? – behzad.nouri Dec 19 '13 at 19:53

1 Answers1

8

The notation X ~ N(μ, σ²) means that X is normally distributed with mean μ and variance σ², so in the RBM training routine, v should be sampled from such a distribution. In NumPy terms, that's

v = sigma * np.random.randn(v_size) + b + sigma * W.dot(h)

Or use scipy.stats.norm for better readable code.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836