update func in RBM: change the for loop to while loop to sample a
instance randomly rather than scheduled and finish when it satisfies the
threshold
update func in RBM: use while loop and sample an instance randomly and
finish the process when it reaches the threshold.