def check_grad(self,data,labels,epsilon=1e-4):
        cost,grad,_ = self.costAndGrad(data,labels)
        for param,delta in zip(self.stack,grad):
            w,b = param
            dw,db = delta
            dw.copy_to_host()
            w.copy_to_host()
            for i in xrange(w.shape[0]):
                for j in xrange(w.shape[1]):
                    w.numpy_array[i,j] += epsilon
                    w.copy_to_device()
                    costP,_,_ = self.costAndGrad(data,labels)
                    numGrad = (costP - cost) / epsilon
                    w.numpy_array[i,j] -= epsilon
                    print "Analytic %f, Numeric %f"%(dw.numpy_array[i,j],numGrad)
dataset/ETHPy150Open amaas/stanford-ctc/ctc_fast/nnets/nnet.py/NNet.check_grad/original