Example #1
0
void test_resize(char *filename)
{
    image im = load_image(filename, 0,0, 3);
    float mag = mag_array(im.data, im.w*im.h*im.c);
    printf("L2 Norm: %f\n", mag);
    image gray = grayscale_image(im);

    image sat2 = copy_image(im);
    saturate_image(sat2, 2);

    image sat5 = copy_image(im);
    saturate_image(sat5, .5);

    image exp2 = copy_image(im);
    exposure_image(exp2, 2);

    image exp5 = copy_image(im);
    exposure_image(exp5, .5);

    #ifdef GPU
    image r = resize_image(im, im.w, im.h);
    image black = make_image(im.w*2 + 3, im.h*2 + 3, 9);
    image black2 = make_image(im.w, im.h, 3);

    float *r_gpu = cuda_make_array(r.data, r.w*r.h*r.c);
    float *black_gpu = cuda_make_array(black.data, black.w*black.h*black.c);
    float *black2_gpu = cuda_make_array(black2.data, black2.w*black2.h*black2.c);
    shortcut_gpu(3, r.w, r.h, 1, r_gpu, black.w, black.h, 3, black_gpu);
    //flip_image(r);
    //shortcut_gpu(3, r.w, r.h, 1, r.data, black.w, black.h, 3, black.data);

    shortcut_gpu(3, black.w, black.h, 3, black_gpu, black2.w, black2.h, 1, black2_gpu);
    cuda_pull_array(black_gpu, black.data, black.w*black.h*black.c);
    cuda_pull_array(black2_gpu, black2.data, black2.w*black2.h*black2.c);
    show_image_layers(black, "Black");
    show_image(black2, "Recreate");
    #endif

    show_image(im, "Original");
    show_image(gray, "Gray");
    show_image(sat2, "Saturation-2");
    show_image(sat5, "Saturation-.5");
    show_image(exp2, "Exposure-2");
    show_image(exp5, "Exposure-.5");
#ifdef OPENCV
    cvWaitKey(0);
#endif
}
void backward_shortcut_layer_gpu(const layer l, network net) {
	gradient_array_gpu(l.output_gpu, l.outputs * l.batch, l.activation,
			l.delta_gpu, net.st);
	axpy_gpu(l.outputs * l.batch, l.alpha, l.delta_gpu, 1, net.delta_gpu, 1,
			net.st);
	shortcut_gpu(l.batch, l.out_w, l.out_h, l.out_c, l.delta_gpu, l.w, l.h, l.c,
			1, l.beta, net.layers[l.index].delta_gpu, net.st);
}
Example #3
0
void forward_shortcut_layer_gpu(const layer l, network net)
{
    copy_gpu(l.outputs*l.batch, net.input_gpu, 1, l.output_gpu, 1);
    shortcut_gpu(l.batch, l.w, l.h, l.c, net.layers[l.index].output_gpu, l.out_w, l.out_h, l.out_c, l.output_gpu);
    activate_array_gpu(l.output_gpu, l.outputs*l.batch, l.activation);
}
Example #4
0
void backward_shortcut_layer_gpu(const layer l, network_state state)
{
    gradient_array_ongpu(l.output_gpu, l.outputs*l.batch, l.activation, l.delta_gpu);
    axpy_ongpu(l.outputs*l.batch, 1, l.delta_gpu, 1, state.delta, 1);
    shortcut_gpu(l.batch, l.out_w, l.out_h, l.out_c, l.delta_gpu, l.w, l.h, l.c, state.net.layers[l.index].delta_gpu);
}