Beispiel #1
0
    # rbm.load_params('rbm_trained.pkl')
    # make an optimizer to train it (AdaDelta is a good default)

    # optimizer = SGD(model=rbm, dataset=mnist, batch_size=20, learning_rate=0.1, lr_decay=False, nesterov_momentum=False, momentum=False)

    optimizer = Optimizer(lr_decay=False, learning_rate=0.1, model=rbm, dataset=mnist, batch_size=20, save_frequency=1)

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

    # perform training!
    optimizer.train(monitor_channels=ll)
    # test it on some images!
    test_data = mnist.getSubset(TEST)[0]
    test_data = test_data[:25].eval()
    # 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)
        )
    )
    image.save('rbm_test.png')

    # Construct image from the preds matrix
    image = Image.fromarray(
        tile_raster_images(