Пример #1
0
 def post_epoch(*args):
     save_params(*args)
     # Save visualization weights.
     W_norm = utils.rescale(args[0].W)
     img = Image.fromarray(np.uint8(utils.tile(W_norm, channel_count=3) * 255))
     img.save(os.path.join(output_dir, ('w%i.png' % args[1])))
     # Estimate sparsity from subset of data.
     h_mean = grbm.sample_h_noisy_relu(args[0], inputs[0:5000], True)[1]
     mean_activation = np.mean(h_mean > 0)
     print 'approx mean activation: %f' % mean_activation
Пример #2
0
def imtile(X, *args, **kwargs):
    if 'v' in kwargs:
        v = kwargs['v']
        kwargs['vmin'] = -v
        kwargs['vmax'] = v
        del kwargs['v']
    tile_kwargs = {}
    if 'channel_count' in kwargs:
        tile_kwargs['channel_count'] = kwargs['channel_count']
        del kwargs['channel_count']
    matplotlib.pyplot.imshow(utils.tile(X, **tile_kwargs), *args, **kwargs)
Пример #3
0
 def post_epoch(*args):
     save_params(*args)
     # Save visualization weights.
     W_norm = utils.rescale(args[0].W)
     img = Image.fromarray(
         np.uint8(utils.tile(W_norm, channel_count=3) * 255))
     img.save(os.path.join(output_dir, ('w%i.png' % args[1])))
     # Estimate sparsity from subset of data.
     h_mean = grbm.sample_h_noisy_relu(args[0], inputs[0:5000], True)[1]
     mean_activation = np.mean(h_mean > 0)
     print 'approx mean activation: %f' % mean_activation
Пример #4
0
def imtile(X, *args, **kwargs):
    if 'v' in kwargs:
        v = kwargs['v']
        kwargs['vmin'] = -v
        kwargs['vmax'] = v
        del kwargs['v']
    tile_kwargs = {}
    if 'channel_count' in kwargs:
        tile_kwargs['channel_count'] = kwargs['channel_count']
        del kwargs['channel_count']
    matplotlib.pyplot.imshow(utils.tile(X, **tile_kwargs), *args, **kwargs)
Пример #5
0
    def post_epoch(*args):
        W_norm = utils.rescale(args[0].W)
        utils.save_image(utils.tile(W_norm),
                         os.path.join(output_dir, ('w%i.png' % args[1])))

        # Estimate sparsity from subset of data.
        h_mean = grbm.sample_h_noisy_relu(args[0], inputs[0:5000], True)[1]
        mean_activation = np.mean(h_mean > 0)
        print 'approx mean activation: %f' % mean_activation
        
        # The callback from optimize.sgd needs modifying so that it
        # passes the reconstrcution error as an argument to make this
        # work. (This was used when I did the original experiments.)
        # error_history.append(args[2])
        sparsity_history.append(mean_activation)
        
        save_params(args[0], args[1])