コード例 #1
0
ファイル: test_ais.py プロジェクト: Alienfeel/pylearn2
def ais_data(fname, do_exact=True):

    rbm_params = load_rbm_params(fname)

    # load data to set visible biases to ML solution
    from pylearn.datasets import MNIST
    dataset = MNIST.train_valid_test()
    data = numpy.asarray(dataset.train.x, dtype=config.floatX)

    # run ais using B=0 model with ML visible biases
    t1 = time.time()
    (logz, log_var_dz), aisobj = rbm_tools.rbm_ais(rbm_params, n_runs=100, seed=123, data=data)
    print 'AIS logZ         : %f' % logz
    print '    log_variance : %f' % log_var_dz
    print 'Elapsed time: ', time.time() - t1

    if do_exact:
        exact_logz = compute_logz(rbm_params)
        print 'Exact logZ = %f' % exact_logz
        numpy.testing.assert_almost_equal(exact_logz, logz, decimal=0)
コード例 #2
0
ファイル: mnist.py プロジェクト: jaberg/pylearn
    def __init__(self, which_set, center = False):

        #dear pylearn.datasets.MNIST: there is no such thing as the MNIST validation set. quit pretending that there is.
        orig = i_hate_python.train_valid_test(ntrain=60000,nvalid=0,ntest=10000)

        Xs = {
                'train' : orig.train.x,
                'test'  : orig.test.x
            }

        X = N.cast['float32'](Xs[which_set])

        if center:
            assert False

        view_converter = dense_design_matrix.DefaultViewConverter((28,28,1))

        super(MNIST,self).__init__(X = X, view_converter = view_converter)

        assert not N.any(N.isnan(self.X))
コード例 #3
0
ファイル: mnist.py プロジェクト: LeeEdel/pylearn
    def __init__(self, which_set, center = False):

        #dear pylearn.datasets.MNIST: there is no such thing as the MNIST validation set. quit pretending that there is.
        orig = i_hate_python.train_valid_test(ntrain=60000,nvalid=0,ntest=10000)

        Xs = {
                'train' : orig.train.x,
                'test'  : orig.test.x
            }

        X = N.cast['float32'](Xs[which_set])

        if center:
            assert False

        view_converter = dense_design_matrix.DefaultViewConverter((28,28,1))

        super(MNIST,self).__init__(X = X, view_converter = view_converter)

        assert not N.any(N.isnan(self.X))
コード例 #4
0
ファイル: test_ais.py プロジェクト: wqren/pylearn
def ais_data(fname, do_exact=True):

    rbm_params = load_rbm_params(fname)

    # load data to set visible biases to ML solution
    from pylearn.datasets import MNIST
    dataset = MNIST.train_valid_test()
    data = numpy.asarray(dataset.train.x, dtype=config.floatX)

    # run ais using B=0 model with ML visible biases
    t1 = time.time()
    (logz, log_var_dz), aisobj = rbm_tools.rbm_ais(rbm_params,
                                                   n_runs=100,
                                                   seed=123,
                                                   data=data)
    print 'AIS logZ         : %f' % logz
    print '    log_variance : %f' % log_var_dz
    print 'Elapsed time: ', time.time() - t1

    if do_exact:
        exact_logz = compute_logz(rbm_params)
        print 'Exact logZ = %f' % exact_logz
        numpy.testing.assert_almost_equal(exact_logz, logz, decimal=0)