def cost(self, v, subsample_ids=None):
        num_points = v.shape[0]
        # positive phase
        pos_h_samples = self.propup(v, subsample_ids)
        # negative phase
        nh0 = self.p[:num_points]
        for i in xrange(self.n):
            neg_v_samples, neg_h_samples = self.gibbs_hvh(nh0, 
                                                    subsample_ids=subsample_ids, 
                                                    fw=True)
            nh0 = neg_h_samples[0]
        # compute gradients
        grad = self._grad(v, pos_h_samples, neg_v_samples, neg_h_samples)
        self.p[:num_points] = nh0
        # compute reconstruction error
        reconstruction = self.propdown(pos_h_samples[0], subsample_ids)[1]
        cost = np.abs(v - reconstruction).sum(1).mean(0)
        return cost, grad
Compute the 'cost' and gradient using FPCD.
dataset/ETHPy150Open theusual/kaggle-seeclickfix-ensemble/Miroslaw/sparserbm.py/SparseRBM.cost