basic implementation of rbm