DBN and RBM updated: update function