def trainOnDataset(self, dataset):
        """This function trains the RBM using the same algorithm and
        implementation presented in:
        http://www.cs.toronto.edu/~hinton/MatlabForSciencePaper.html"""
        cfg = self.cfg
        for rows in dataset.randomBatches(self.datasetField, cfg.batchSize):
            olduw, olduhb, olduvb = \
                zeros((self.rbm.visibleDim, self.rbm.hiddenDim)), \
                zeros(self.rbm.hiddenDim), zeros(self.rbm.visibleDim)

            for t in range(cfg.maxIter):
                #print("*** Iteration %2d **************************************" % t)

                params = self.rbm.params
                params = params.reshape((self.rbm.visibleDim, self.rbm.hiddenDim))
                biasParams = self.rbm.biasParams

                mm = cfg.iniMm if t < cfg.mmSwitchIter else cfg.finMm

                w, hb, vb = self.calcUpdateByRows(rows)

                #print("Delta: ")
                #print("Weight: ",)
                #print(w)
                #print("Visible bias: ",)
                #print(vb)
                #print("Hidden bias: ",)
                #print(hb)
                #print("")

                olduw = uw = olduw * mm + \
                	cfg.rWeights * (w - cfg.weightCost * params)
                olduhb = uhb = olduhb * mm + cfg.rHidBias * hb
                olduvb = uvb = olduvb * mm + cfg.rVisBias * vb

                #print("Delta after momentum: ")
                #print("Weight: ",)
                #print(uw)
                #print("Visible bias: ",)
                #print(uvb)
                #print("Hidden bias: ",)
                #print(uhb)
                #print("")

                # update the parameters of the original rbm
                params += uw
                biasParams += uhb

                # Create a new inverted rbm with correct parameters
                invBiasParams = self.invRbm.biasParams
                invBiasParams += uvb
                self.invRbm = self.rbm.invert()
                self.invRbm.biasParams[:] = invBiasParams

                #print("Updated ")
                #print("Weight: ",)
                #print(self.rbm.connections[self.rbm['visible']][0].params.reshape( \)
                #    (self.rbm.indim, self.rbm.outdim))
                #print("Visible bias: ",)
                #print(self.invRbm.connections[self.invRbm['bias']][0].params)
                #print("Hidden bias: ",)
                #print(self.rbm.connections[self.rbm['bias']][0].params)
                #print("")
dataset/ETHPy150Open pybrain/pybrain/pybrain/unsupervised/trainers/rbm.py/RbmGibbsTrainer.trainOnDataset/original