implement contrastive divergence