Esempio n. 1
0
    log.info("Creating RBM!")

    # grab the MNIST dataset
    mnist = MNIST(concat_train_valid=False)
    # create the RBM
    rng = numpy.random.RandomState(1234)
    mrg = theano.tensor.shared_randomstreams.RandomStreams(rng.randint(2**30))
    config_args = {
        'inputs': (28*28, theano.tensor.matrix('x')),
        'hiddens': 500,
        'k': 15,
        'weights_init': 'uniform',
        'weights_interval': 4*numpy.sqrt(6./28*28+500),
        'mrg': mrg
    }
    rbm = RBM(**config_args)
    # rbm.load_params('outputs/rbm/trained_epoch_15.pkl')

    optimizer = Optimizer(learning_rate=0.1, model=rbm, dataset=mnist, batch_size=20, epochs=15)


    # perform training!
    optimizer.train()
    # test it on some images!
    test_data = mnist.test_inputs[:25]
    # use the run function!
    preds = rbm.run(test_data)

    # Construct image from the test matrix
    image = Image.fromarray(
        tile_raster_images(
Esempio n. 2
0
    log.info("Creating RBM!")

    # grab the MNIST dataset
    mnist = MNIST(concat_train_valid=False)
    # create the RBM
    rng = numpy.random.RandomState(1234)
    mrg = theano.tensor.shared_randomstreams.RandomStreams(rng.randint(2**30))
    config_args = {
        'inputs': (28*28, theano.tensor.matrix('x')),
        'hiddens': 500,
        'k': 15,
        'weights_init': 'uniform',
        'weights_interval': 4*numpy.sqrt(6./28*28+500),
        'mrg': mrg
    }
    rbm = RBM(**config_args)
    # rbm.load_params('outputs/rbm/trained_epoch_15.pkl')

    optimizer = Optimizer(learning_rate=0.1, model=rbm, dataset=mnist, batch_size=20, epochs=15)


    # perform training!
    optimizer.train()
    # test it on some images!
    test_data = mnist.test_inputs[:25]
    # use the run function!
    preds = rbm.run(test_data)

    if has_pil:
        # Construct image from the test matrix
        image = Image.fromarray(
Esempio n. 3
0
    log.info("Creating RBM!")

    # grab the MNIST dataset
    mnist = MNIST(concat_train_valid=False)
    # create the RBM
    rng = numpy.random.RandomState(1234)
    mrg = theano.tensor.shared_randomstreams.RandomStreams(rng.randint(2**30))
    config_args = {
        'input_size': 28 * 28,
        'hidden_size': 500,
        'k': 15,
        'weights_init': 'uniform',
        'weights_interval': 4 * numpy.sqrt(6. / 28 * 28 + 500),
        'mrg': mrg
    }
    rbm = RBM(**config_args)
    # rbm.load_params('rbm_trained.pkl')

    optimizer = Optimizer(learning_rate=0.1,
                          model=rbm,
                          dataset=mnist,
                          batch_size=20,
                          epochs=15)

    ll = Monitor('pseudo-log', rbm.get_monitors()['pseudo-log'])

    # perform training!
    optimizer.train(monitor_channels=ll)
    # test it on some images!
    test_data = mnist.test_inputs[:25]
    # use the run function!
Esempio n. 4
0
    log.info("Creating RBM!")

    # grab the MNIST dataset
    mnist = MNIST(concat_train_valid=False)
    # create the RBM
    rng = numpy.random.RandomState(1234)
    mrg = theano.tensor.shared_randomstreams.RandomStreams(rng.randint(2 ** 30))
    config_args = {
        "input_size": 28 * 28,
        "hidden_size": 500,
        "k": 15,
        "weights_init": "uniform",
        "weights_interval": 4 * numpy.sqrt(6.0 / 28 * 28 + 500),
        "mrg": mrg,
    }
    rbm = RBM(**config_args)
    # rbm.load_params('rbm_trained.pkl')

    optimizer = Optimizer(learning_rate=0.1, model=rbm, dataset=mnist, batch_size=20, epochs=15)

    ll = Monitor("pseudo-log", rbm.get_monitors()["pseudo-log"])

    # perform training!
    optimizer.train(monitor_channels=ll)
    # test it on some images!
    test_data = mnist.test_inputs[:25]
    # use the run function!
    preds = rbm.run(test_data)

    # Construct image from the test matrix
    image = Image.fromarray(tile_raster_images(X=test_data, img_shape=(28, 28), tile_shape=(5, 5), tile_spacing=(1, 1)))