Exemplo n.º 1
0
 def callback(epoch, paramvec, vals):
     print 'epoch {}: {}'.format(
         epoch, prediction_error(paramvec, test_im, test_angle))
     update_training_progress(fig, ax, line, vals)
     plot_images_and_angles(test_im, predict(test_im, paramvec),
                            prediction_fig)
     if save_figs: prediction_fig.figure.savefig('orientations.png')
Exemplo n.º 2
0
 def callback(epoch, paramvec, vals):
     print 'epoch {}: {}'.format(epoch, prediction_error(paramvec, test_im, test_angle))
     update_training_progress(fig, ax, line, vals)
     plot_images_and_angles(test_im, predict(test_im, paramvec), prediction_fig)
     if save_figs: prediction_fig.figure.savefig('orientations.png')
Exemplo n.º 3
0
    fig.draw_artist(line)
    if save_figs: fig.savefig('training.png')
    plt.pause(1e-6)


if __name__ == "__main__":
    npr.seed(0)
    plt.ion()

    # load training data and plot some examples
    (images,
     angles), (test_im,
               test_angle) = load_training_data('data/labeled_images.pkl',
                                                augmentation=19,
                                                hold_out=80)
    data_fig = plot_images_and_angles(images[:80], angles[:80])
    if save_figs: data_fig.figure.savefig('data.png')

    imsize = images.shape[1]
    hdims = [50, 50]
    # l2_reg = empirical_l2_reg(images, hdims)
    l2_reg = 0.

    paramvec, unflatten = flatten(init_gmlp(hdims, imsize, 1))
    predict, loss, prediction_error = make_regression(l2_reg, unflatten)

    # make a figure for training progress
    fig, ax = plt.subplots()
    line, = ax.plot([])
    plt.draw()
Exemplo n.º 4
0
def update_training_progress(fig, ax, line, vals):
    line.set_data(range(1, len(vals)+1), vals)
    ax.set_ylim(min(vals), np.percentile(vals, 99))
    ax.set_xlim(1, len(vals)+1)
    fig.draw_artist(line)
    if save_figs: fig.savefig('training.png')
    plt.pause(1e-6)

if __name__ == "__main__":
    npr.seed(0)
    plt.ion()

    # load training data and plot some examples
    (images, angles), (test_im, test_angle) = load_training_data(
        'data/labeled_images.pkl', augmentation=19, hold_out=80)
    data_fig = plot_images_and_angles(images[:80], angles[:80])
    if save_figs: data_fig.figure.savefig('data.png')

    imsize = images.shape[1]
    hdims = [50, 50]
    # l2_reg = empirical_l2_reg(images, hdims)
    l2_reg = 0.

    paramvec, unflatten = flatten(init_gmlp(hdims, imsize, 1))
    predict, loss, prediction_error = make_regression(l2_reg, unflatten)

    # make a figure for training progress
    fig, ax = plt.subplots()
    line, = ax.plot([])
    plt.draw()