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
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
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])