Ejemplo n.º 1
0
        shuffle_batches=shuffle_batches,
        shuffle_examples=shuffle_examples)

    print 'Building'

    trainer.build()

    print 'Training'

    start_time = time.clock()
    trainer.train()
    end_time = time.clock()
    print 'The training took %i seconds' % (end_time - start_time)

    print 'Display weights'

    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    from filter_plot import tile_raster_images

    W = np.transpose(model.layer[0].W.get_value())

    # histogram = np.histogram(W,bins=1000,range=(-.2,.2))
    # np.savetxt(core_path + "_hist0.csv", histogram[0], delimiter=",")
    # np.savetxt(core_path + "_hist1.csv", histogram[1], delimiter=",")

    W = tile_raster_images(W, (28, 28), (4, 4), (2, 2))
    plt.imshow(W, cmap=cm.Greys_r)
    # plt.show()
    plt.savefig(core_path + '_features.png')
Ejemplo n.º 2
0
    monitor_step = 3
    
    model = PI_MNIST_model(rng = rng)
    
    trainer = Trainer(rng = rng,
        train_set = train_set, valid_set = valid_set, test_set = test_set,
        model = model,
        LR = LR, LR_decay = 0.98, LR_fin = LR/100.,
        batch_size = batch_size, gpu_batches = gpu_batches,
        n_epoch = n_epoch, monitor_step = monitor_step,
        shuffle_batches = False, shuffle_examples = True)

    print 'Building'
    
    trainer.build()
    
    print 'Training'
    
    trainer.train()
    
    print 'Display weights'
    
    W = np.transpose(model.layer[0].W.get_value())
    print np.max((W==0.))
    W = tile_raster_images(W,(28,28),(10,10),(2, 2))
    plt.imshow(W, cmap = cm.Greys_r)
    plt.show()

    end_time = time.clock()
    print 'The code ran for %i seconds'%(end_time - start_time)
    
Ejemplo n.º 3
0
        n_epoch = n_epoch, monitor_step = monitor_step,
        shuffle_batches = shuffle_batches, shuffle_examples = shuffle_examples)
    
    print 'Building'
    
    trainer.build()
    
    print 'Training'
    
    start_time = time.clock()  
    trainer.train()
    end_time = time.clock()
    print 'The training took %i seconds'%(end_time - start_time)
    
    print 'Display weights'
    
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    from filter_plot import tile_raster_images
    
    W = np.transpose(model.layer[0].W.get_value())
    
    # histogram = np.histogram(W,bins=1000,range=(-.2,.2))
    # np.savetxt(core_path + "_hist0.csv", histogram[0], delimiter=",")
    # np.savetxt(core_path + "_hist1.csv", histogram[1], delimiter=",")
    
    W = tile_raster_images(W,(28,28),(4,4),(2, 2))
    plt.imshow(W, cmap = cm.Greys_r)
    # plt.show()
    plt.savefig(core_path + '_features.png')