'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( 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(
# 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))) image.save('rbm_test.png') # Construct image from the preds matrix image = Image.fromarray( tile_raster_images(X=preds, img_shape=(28, 28), tile_shape=(5, 5), tile_spacing=(1, 1)))