Added contrastive divergence functions