Code to accompany the paper "Cardinality Restricted Boltzmann Machines, NIPS 2012".