12 if (strcmp(s,
"seg")==0)
return SEG;
13 if (strcmp(s,
"sse")==0)
return SSE;
14 if (strcmp(s,
"masked")==0)
return MASKED;
15 if (strcmp(s,
"smooth")==0)
return SMOOTH;
16 if (strcmp(s,
"L1")==0)
return L1;
17 if (strcmp(s,
"wgan")==0)
return WGAN;
18 fprintf(stderr,
"Couldn't find cost type %s, going with SSE\n", s);
43 fprintf(stderr,
"cost %4d\n", inputs);
52 l.
delta = calloc(inputs*batch,
sizeof(
float));
53 l.
output = calloc(inputs*batch,
sizeof(
float));
54 l.
cost = calloc(1,
sizeof(
float));
62 l.delta_gpu = cuda_make_array(l.
output, inputs*batch);
63 l.output_gpu = cuda_make_array(l.
delta, inputs*batch);
75 cuda_free(l->delta_gpu);
76 cuda_free(l->output_gpu);
77 l->delta_gpu = cuda_make_array(l->
delta, inputs*l->
batch);
78 l->output_gpu = cuda_make_array(l->
output, inputs*l->
batch);
84 if (!net.
truth)
return;
118 int float_abs_compare (
const void * a,
const void * b)
120 float fa = *(
const float*) a;
122 float fb = *(
const float*) b;
124 return (fa > fb) - (fa < fb);
129 if (!net.
truth)
return;
138 l1_gpu(l.
batch*l.
inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu);
142 l2_gpu(l.
batch*l.
inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu);
157 float thresh = l.
delta[n];
159 printf(
"%f\n", thresh);
void backward_cost_layer(const cost_layer l, network net)
void(* forward_gpu)(struct layer, struct network)
void l2_cpu(int n, float *pred, float *truth, float *delta, float *error)
void(* backward_gpu)(struct layer, struct network)
void axpy_gpu(int N, float ALPHA, float *X, int INCX, float *Y, int INCY)
char * get_cost_string(COST_TYPE a)
void smooth_l1_cpu(int n, float *pred, float *truth, float *delta, float *error)
void(* forward)(struct layer, struct network)
void supp_gpu(int N, float ALPHA, float *X, int INCX)
void smooth_l1_gpu(int n, float *pred, float *truth, float *delta, float *error)
void scale_mask_gpu(int N, float *X, float mask_num, float *mask, float scale)
void scal_gpu(int N, float ALPHA, float *X, int INCX)
void axpy_cpu(int N, float ALPHA, float *X, int INCX, float *Y, int INCY)
void(* backward)(struct layer, struct network)
void resize_cost_layer(cost_layer *l, int inputs)
void l1_cpu(int n, float *pred, float *truth, float *delta, float *error)
void add_gpu(int N, float ALPHA, float *X, int INCX)
float sum_array(float *a, int n)
void l1_gpu(int n, float *pred, float *truth, float *delta, float *error)
cost_layer make_cost_layer(int batch, int inputs, COST_TYPE cost_type, float scale)
void wgan_gpu(int n, float *pred, float *truth, float *delta, float *error)
void mask_gpu(int N, float *X, float mask_num, float *mask, float val)
COST_TYPE get_cost_type(char *s)
void l2_gpu(int n, float *pred, float *truth, float *delta, float *error)
void forward_cost_layer(cost_layer l, network net)