darknet  v3
region_layer.c
Go to the documentation of this file.
1 #include "region_layer.h"
2 #include "activations.h"
3 #include "blas.h"
4 #include "box.h"
5 #include "cuda.h"
6 #include "utils.h"
7 
8 #include <stdio.h>
9 #include <assert.h>
10 #include <string.h>
11 #include <stdlib.h>
12 
13 layer make_region_layer(int batch, int w, int h, int n, int classes, int coords)
14 {
15  layer l = {0};
16  l.type = REGION;
17 
18  l.n = n;
19  l.batch = batch;
20  l.h = h;
21  l.w = w;
22  l.c = n*(classes + coords + 1);
23  l.out_w = l.w;
24  l.out_h = l.h;
25  l.out_c = l.c;
26  l.classes = classes;
27  l.coords = coords;
28  l.cost = calloc(1, sizeof(float));
29  l.biases = calloc(n*2, sizeof(float));
30  l.bias_updates = calloc(n*2, sizeof(float));
31  l.outputs = h*w*n*(classes + coords + 1);
32  l.inputs = l.outputs;
33  l.truths = 30*(l.coords + 1);
34  l.delta = calloc(batch*l.outputs, sizeof(float));
35  l.output = calloc(batch*l.outputs, sizeof(float));
36  int i;
37  for(i = 0; i < n*2; ++i){
38  l.biases[i] = .5;
39  }
40 
43 #ifdef GPU
44  l.forward_gpu = forward_region_layer_gpu;
45  l.backward_gpu = backward_region_layer_gpu;
46  l.output_gpu = cuda_make_array(l.output, batch*l.outputs);
47  l.delta_gpu = cuda_make_array(l.delta, batch*l.outputs);
48 #endif
49 
50  fprintf(stderr, "detection\n");
51  srand(0);
52 
53  return l;
54 }
55 
56 void resize_region_layer(layer *l, int w, int h)
57 {
58  l->w = w;
59  l->h = h;
60 
61  l->outputs = h*w*l->n*(l->classes + l->coords + 1);
62  l->inputs = l->outputs;
63 
64  l->output = realloc(l->output, l->batch*l->outputs*sizeof(float));
65  l->delta = realloc(l->delta, l->batch*l->outputs*sizeof(float));
66 
67 #ifdef GPU
68  cuda_free(l->delta_gpu);
69  cuda_free(l->output_gpu);
70 
71  l->delta_gpu = cuda_make_array(l->delta, l->batch*l->outputs);
72  l->output_gpu = cuda_make_array(l->output, l->batch*l->outputs);
73 #endif
74 }
75 
76 box get_region_box(float *x, float *biases, int n, int index, int i, int j, int w, int h, int stride)
77 {
78  box b;
79  b.x = (i + x[index + 0*stride]) / w;
80  b.y = (j + x[index + 1*stride]) / h;
81  b.w = exp(x[index + 2*stride]) * biases[2*n] / w;
82  b.h = exp(x[index + 3*stride]) * biases[2*n+1] / h;
83  return b;
84 }
85 
86 float delta_region_box(box truth, float *x, float *biases, int n, int index, int i, int j, int w, int h, float *delta, float scale, int stride)
87 {
88  box pred = get_region_box(x, biases, n, index, i, j, w, h, stride);
89  float iou = box_iou(pred, truth);
90 
91  float tx = (truth.x*w - i);
92  float ty = (truth.y*h - j);
93  float tw = log(truth.w*w / biases[2*n]);
94  float th = log(truth.h*h / biases[2*n + 1]);
95 
96  delta[index + 0*stride] = scale * (tx - x[index + 0*stride]);
97  delta[index + 1*stride] = scale * (ty - x[index + 1*stride]);
98  delta[index + 2*stride] = scale * (tw - x[index + 2*stride]);
99  delta[index + 3*stride] = scale * (th - x[index + 3*stride]);
100  return iou;
101 }
102 
103 void delta_region_mask(float *truth, float *x, int n, int index, float *delta, int stride, int scale)
104 {
105  int i;
106  for(i = 0; i < n; ++i){
107  delta[index + i*stride] = scale*(truth[i] - x[index + i*stride]);
108  }
109 }
110 
111 
112 void delta_region_class(float *output, float *delta, int index, int class, int classes, tree *hier, float scale, int stride, float *avg_cat, int tag)
113 {
114  int i, n;
115  if(hier){
116  float pred = 1;
117  while(class >= 0){
118  pred *= output[index + stride*class];
119  int g = hier->group[class];
120  int offset = hier->group_offset[g];
121  for(i = 0; i < hier->group_size[g]; ++i){
122  delta[index + stride*(offset + i)] = scale * (0 - output[index + stride*(offset + i)]);
123  }
124  delta[index + stride*class] = scale * (1 - output[index + stride*class]);
125 
126  class = hier->parent[class];
127  }
128  *avg_cat += pred;
129  } else {
130  if (delta[index] && tag){
131  delta[index + stride*class] = scale * (1 - output[index + stride*class]);
132  return;
133  }
134  for(n = 0; n < classes; ++n){
135  delta[index + stride*n] = scale * (((n == class)?1 : 0) - output[index + stride*n]);
136  if(n == class) *avg_cat += output[index + stride*n];
137  }
138  }
139 }
140 
141 float logit(float x)
142 {
143  return log(x/(1.-x));
144 }
145 
146 float tisnan(float x)
147 {
148  return (x != x);
149 }
150 
151 int entry_index(layer l, int batch, int location, int entry)
152 {
153  int n = location / (l.w*l.h);
154  int loc = location % (l.w*l.h);
155  return batch*l.outputs + n*l.w*l.h*(l.coords+l.classes+1) + entry*l.w*l.h + loc;
156 }
157 
159 {
160  int i,j,b,t,n;
161  memcpy(l.output, net.input, l.outputs*l.batch*sizeof(float));
162 
163 #ifndef GPU
164  for (b = 0; b < l.batch; ++b){
165  for(n = 0; n < l.n; ++n){
166  int index = entry_index(l, b, n*l.w*l.h, 0);
167  activate_array(l.output + index, 2*l.w*l.h, LOGISTIC);
168  index = entry_index(l, b, n*l.w*l.h, l.coords);
169  if(!l.background) activate_array(l.output + index, l.w*l.h, LOGISTIC);
170  index = entry_index(l, b, n*l.w*l.h, l.coords + 1);
171  if(!l.softmax && !l.softmax_tree) activate_array(l.output + index, l.classes*l.w*l.h, LOGISTIC);
172  }
173  }
174  if (l.softmax_tree){
175  int i;
176  int count = l.coords + 1;
177  for (i = 0; i < l.softmax_tree->groups; ++i) {
178  int group_size = l.softmax_tree->group_size[i];
179  softmax_cpu(net.input + count, group_size, l.batch, l.inputs, l.n*l.w*l.h, 1, l.n*l.w*l.h, l.temperature, l.output + count);
180  count += group_size;
181  }
182  } else if (l.softmax){
183  int index = entry_index(l, 0, 0, l.coords + !l.background);
184  softmax_cpu(net.input + index, l.classes + l.background, l.batch*l.n, l.inputs/l.n, l.w*l.h, 1, l.w*l.h, 1, l.output + index);
185  }
186 #endif
187 
188  memset(l.delta, 0, l.outputs * l.batch * sizeof(float));
189  if(!net.train) return;
190  float avg_iou = 0;
191  float recall = 0;
192  float avg_cat = 0;
193  float avg_obj = 0;
194  float avg_anyobj = 0;
195  int count = 0;
196  int class_count = 0;
197  *(l.cost) = 0;
198  for (b = 0; b < l.batch; ++b) {
199  if(l.softmax_tree){
200  int onlyclass = 0;
201  for(t = 0; t < 30; ++t){
202  box truth = float_to_box(net.truth + t*(l.coords + 1) + b*l.truths, 1);
203  if(!truth.x) break;
204  int class = net.truth[t*(l.coords + 1) + b*l.truths + l.coords];
205  float maxp = 0;
206  int maxi = 0;
207  if(truth.x > 100000 && truth.y > 100000){
208  for(n = 0; n < l.n*l.w*l.h; ++n){
209  int class_index = entry_index(l, b, n, l.coords + 1);
210  int obj_index = entry_index(l, b, n, l.coords);
211  float scale = l.output[obj_index];
212  l.delta[obj_index] = l.noobject_scale * (0 - l.output[obj_index]);
213  float p = scale*get_hierarchy_probability(l.output + class_index, l.softmax_tree, class, l.w*l.h);
214  if(p > maxp){
215  maxp = p;
216  maxi = n;
217  }
218  }
219  int class_index = entry_index(l, b, maxi, l.coords + 1);
220  int obj_index = entry_index(l, b, maxi, l.coords);
221  delta_region_class(l.output, l.delta, class_index, class, l.classes, l.softmax_tree, l.class_scale, l.w*l.h, &avg_cat, !l.softmax);
222  if(l.output[obj_index] < .3) l.delta[obj_index] = l.object_scale * (.3 - l.output[obj_index]);
223  else l.delta[obj_index] = 0;
224  l.delta[obj_index] = 0;
225  ++class_count;
226  onlyclass = 1;
227  break;
228  }
229  }
230  if(onlyclass) continue;
231  }
232  for (j = 0; j < l.h; ++j) {
233  for (i = 0; i < l.w; ++i) {
234  for (n = 0; n < l.n; ++n) {
235  int box_index = entry_index(l, b, n*l.w*l.h + j*l.w + i, 0);
236  box pred = get_region_box(l.output, l.biases, n, box_index, i, j, l.w, l.h, l.w*l.h);
237  float best_iou = 0;
238  for(t = 0; t < 30; ++t){
239  box truth = float_to_box(net.truth + t*(l.coords + 1) + b*l.truths, 1);
240  if(!truth.x) break;
241  float iou = box_iou(pred, truth);
242  if (iou > best_iou) {
243  best_iou = iou;
244  }
245  }
246  int obj_index = entry_index(l, b, n*l.w*l.h + j*l.w + i, l.coords);
247  avg_anyobj += l.output[obj_index];
248  l.delta[obj_index] = l.noobject_scale * (0 - l.output[obj_index]);
249  if(l.background) l.delta[obj_index] = l.noobject_scale * (1 - l.output[obj_index]);
250  if (best_iou > l.thresh) {
251  l.delta[obj_index] = 0;
252  }
253 
254  if(*(net.seen) < 12800){
255  box truth = {0};
256  truth.x = (i + .5)/l.w;
257  truth.y = (j + .5)/l.h;
258  truth.w = l.biases[2*n]/l.w;
259  truth.h = l.biases[2*n+1]/l.h;
260  delta_region_box(truth, l.output, l.biases, n, box_index, i, j, l.w, l.h, l.delta, .01, l.w*l.h);
261  }
262  }
263  }
264  }
265  for(t = 0; t < 30; ++t){
266  box truth = float_to_box(net.truth + t*(l.coords + 1) + b*l.truths, 1);
267 
268  if(!truth.x) break;
269  float best_iou = 0;
270  int best_n = 0;
271  i = (truth.x * l.w);
272  j = (truth.y * l.h);
273  box truth_shift = truth;
274  truth_shift.x = 0;
275  truth_shift.y = 0;
276  for(n = 0; n < l.n; ++n){
277  int box_index = entry_index(l, b, n*l.w*l.h + j*l.w + i, 0);
278  box pred = get_region_box(l.output, l.biases, n, box_index, i, j, l.w, l.h, l.w*l.h);
279  if(l.bias_match){
280  pred.w = l.biases[2*n]/l.w;
281  pred.h = l.biases[2*n+1]/l.h;
282  }
283  pred.x = 0;
284  pred.y = 0;
285  float iou = box_iou(pred, truth_shift);
286  if (iou > best_iou){
287  best_iou = iou;
288  best_n = n;
289  }
290  }
291 
292  int box_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, 0);
293  float iou = delta_region_box(truth, l.output, l.biases, best_n, box_index, i, j, l.w, l.h, l.delta, l.coord_scale * (2 - truth.w*truth.h), l.w*l.h);
294  if(l.coords > 4){
295  int mask_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, 4);
296  delta_region_mask(net.truth + t*(l.coords + 1) + b*l.truths + 5, l.output, l.coords - 4, mask_index, l.delta, l.w*l.h, l.mask_scale);
297  }
298  if(iou > .5) recall += 1;
299  avg_iou += iou;
300 
301  int obj_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, l.coords);
302  avg_obj += l.output[obj_index];
303  l.delta[obj_index] = l.object_scale * (1 - l.output[obj_index]);
304  if (l.rescore) {
305  l.delta[obj_index] = l.object_scale * (iou - l.output[obj_index]);
306  }
307  if(l.background){
308  l.delta[obj_index] = l.object_scale * (0 - l.output[obj_index]);
309  }
310 
311  int class = net.truth[t*(l.coords + 1) + b*l.truths + l.coords];
312  if (l.map) class = l.map[class];
313  int class_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, l.coords + 1);
314  delta_region_class(l.output, l.delta, class_index, class, l.classes, l.softmax_tree, l.class_scale, l.w*l.h, &avg_cat, !l.softmax);
315  ++count;
316  ++class_count;
317  }
318  }
319  *(l.cost) = pow(mag_array(l.delta, l.outputs * l.batch), 2);
320  printf("Region Avg IOU: %f, Class: %f, Obj: %f, No Obj: %f, Avg Recall: %f, count: %d\n", avg_iou/count, avg_cat/class_count, avg_obj/count, avg_anyobj/(l.w*l.h*l.n*l.batch), recall/count, count);
321 }
322 
324 {
325  /*
326  int b;
327  int size = l.coords + l.classes + 1;
328  for (b = 0; b < l.batch*l.n; ++b){
329  int index = (b*size + 4)*l.w*l.h;
330  gradient_array(l.output + index, l.w*l.h, LOGISTIC, l.delta + index);
331  }
332  axpy_cpu(l.batch*l.inputs, 1, l.delta, 1, net.delta, 1);
333  */
334 }
335 
336 void correct_region_boxes(detection *dets, int n, int w, int h, int netw, int neth, int relative)
337 {
338  int i;
339  int new_w=0;
340  int new_h=0;
341  if (((float)netw/w) < ((float)neth/h)) {
342  new_w = netw;
343  new_h = (h * netw)/w;
344  } else {
345  new_h = neth;
346  new_w = (w * neth)/h;
347  }
348  for (i = 0; i < n; ++i){
349  box b = dets[i].bbox;
350  b.x = (b.x - (netw - new_w)/2./netw) / ((float)new_w/netw);
351  b.y = (b.y - (neth - new_h)/2./neth) / ((float)new_h/neth);
352  b.w *= (float)netw/new_w;
353  b.h *= (float)neth/new_h;
354  if(!relative){
355  b.x *= w;
356  b.w *= w;
357  b.y *= h;
358  b.h *= h;
359  }
360  dets[i].bbox = b;
361  }
362 }
363 
364 void get_region_detections(layer l, int w, int h, int netw, int neth, float thresh, int *map, float tree_thresh, int relative, detection *dets)
365 {
366  int i,j,n,z;
367  float *predictions = l.output;
368  if (l.batch == 2) {
369  float *flip = l.output + l.outputs;
370  for (j = 0; j < l.h; ++j) {
371  for (i = 0; i < l.w/2; ++i) {
372  for (n = 0; n < l.n; ++n) {
373  for(z = 0; z < l.classes + l.coords + 1; ++z){
374  int i1 = z*l.w*l.h*l.n + n*l.w*l.h + j*l.w + i;
375  int i2 = z*l.w*l.h*l.n + n*l.w*l.h + j*l.w + (l.w - i - 1);
376  float swap = flip[i1];
377  flip[i1] = flip[i2];
378  flip[i2] = swap;
379  if(z == 0){
380  flip[i1] = -flip[i1];
381  flip[i2] = -flip[i2];
382  }
383  }
384  }
385  }
386  }
387  for(i = 0; i < l.outputs; ++i){
388  l.output[i] = (l.output[i] + flip[i])/2.;
389  }
390  }
391  for (i = 0; i < l.w*l.h; ++i){
392  int row = i / l.w;
393  int col = i % l.w;
394  for(n = 0; n < l.n; ++n){
395  int index = n*l.w*l.h + i;
396  for(j = 0; j < l.classes; ++j){
397  dets[index].prob[j] = 0;
398  }
399  int obj_index = entry_index(l, 0, n*l.w*l.h + i, l.coords);
400  int box_index = entry_index(l, 0, n*l.w*l.h + i, 0);
401  int mask_index = entry_index(l, 0, n*l.w*l.h + i, 4);
402  float scale = l.background ? 1 : predictions[obj_index];
403  dets[index].bbox = get_region_box(predictions, l.biases, n, box_index, col, row, l.w, l.h, l.w*l.h);
404  dets[index].objectness = scale > thresh ? scale : 0;
405  if(dets[index].mask){
406  for(j = 0; j < l.coords - 4; ++j){
407  dets[index].mask[j] = l.output[mask_index + j*l.w*l.h];
408  }
409  }
410 
411  int class_index = entry_index(l, 0, n*l.w*l.h + i, l.coords + !l.background);
412  if(l.softmax_tree){
413 
414  hierarchy_predictions(predictions + class_index, l.classes, l.softmax_tree, 0, l.w*l.h);
415  if(map){
416  for(j = 0; j < 200; ++j){
417  int class_index = entry_index(l, 0, n*l.w*l.h + i, l.coords + 1 + map[j]);
418  float prob = scale*predictions[class_index];
419  dets[index].prob[j] = (prob > thresh) ? prob : 0;
420  }
421  } else {
422  int j = hierarchy_top_prediction(predictions + class_index, l.softmax_tree, tree_thresh, l.w*l.h);
423  dets[index].prob[j] = (scale > thresh) ? scale : 0;
424  }
425  } else {
426  if(dets[index].objectness){
427  for(j = 0; j < l.classes; ++j){
428  int class_index = entry_index(l, 0, n*l.w*l.h + i, l.coords + 1 + j);
429  float prob = scale*predictions[class_index];
430  dets[index].prob[j] = (prob > thresh) ? prob : 0;
431  }
432  }
433  }
434  }
435  }
436  correct_region_boxes(dets, l.w*l.h*l.n, w, h, netw, neth, relative);
437 }
438 
439 #ifdef GPU
440 
441 void forward_region_layer_gpu(const layer l, network net)
442 {
443  copy_gpu(l.batch*l.inputs, net.input_gpu, 1, l.output_gpu, 1);
444  int b, n;
445  for (b = 0; b < l.batch; ++b){
446  for(n = 0; n < l.n; ++n){
447  int index = entry_index(l, b, n*l.w*l.h, 0);
448  activate_array_gpu(l.output_gpu + index, 2*l.w*l.h, LOGISTIC);
449  if(l.coords > 4){
450  index = entry_index(l, b, n*l.w*l.h, 4);
451  activate_array_gpu(l.output_gpu + index, (l.coords - 4)*l.w*l.h, LOGISTIC);
452  }
453  index = entry_index(l, b, n*l.w*l.h, l.coords);
454  if(!l.background) activate_array_gpu(l.output_gpu + index, l.w*l.h, LOGISTIC);
455  index = entry_index(l, b, n*l.w*l.h, l.coords + 1);
456  if(!l.softmax && !l.softmax_tree) activate_array_gpu(l.output_gpu + index, l.classes*l.w*l.h, LOGISTIC);
457  }
458  }
459  if (l.softmax_tree){
460  int index = entry_index(l, 0, 0, l.coords + 1);
461  softmax_tree(net.input_gpu + index, l.w*l.h, l.batch*l.n, l.inputs/l.n, 1, l.output_gpu + index, *l.softmax_tree);
462  } else if (l.softmax) {
463  int index = entry_index(l, 0, 0, l.coords + !l.background);
464  softmax_gpu(net.input_gpu + index, l.classes + l.background, l.batch*l.n, l.inputs/l.n, l.w*l.h, 1, l.w*l.h, 1, l.output_gpu + index);
465  }
466  if(!net.train || l.onlyforward){
467  cuda_pull_array(l.output_gpu, l.output, l.batch*l.outputs);
468  return;
469  }
470 
471  cuda_pull_array(l.output_gpu, net.input, l.batch*l.inputs);
472  forward_region_layer(l, net);
473  //cuda_push_array(l.output_gpu, l.output, l.batch*l.outputs);
474  if(!net.train) return;
475  cuda_push_array(l.delta_gpu, l.delta, l.batch*l.outputs);
476 }
477 
478 void backward_region_layer_gpu(const layer l, network net)
479 {
480  int b, n;
481  for (b = 0; b < l.batch; ++b){
482  for(n = 0; n < l.n; ++n){
483  int index = entry_index(l, b, n*l.w*l.h, 0);
484  gradient_array_gpu(l.output_gpu + index, 2*l.w*l.h, LOGISTIC, l.delta_gpu + index);
485  if(l.coords > 4){
486  index = entry_index(l, b, n*l.w*l.h, 4);
487  gradient_array_gpu(l.output_gpu + index, (l.coords - 4)*l.w*l.h, LOGISTIC, l.delta_gpu + index);
488  }
489  index = entry_index(l, b, n*l.w*l.h, l.coords);
490  if(!l.background) gradient_array_gpu(l.output_gpu + index, l.w*l.h, LOGISTIC, l.delta_gpu + index);
491  }
492  }
493  axpy_gpu(l.batch*l.inputs, 1, l.delta_gpu, 1, net.delta_gpu, 1);
494 }
495 #endif
496 
498 {
499  int i, n;
500  for (i = 0; i < l.w*l.h; ++i){
501  for(n = 0; n < l.n; ++n){
502  int obj_index = entry_index(l, 0, n*l.w*l.h + i, l.coords);
503  l.output[obj_index] = 0;
504  }
505  }
506 }
507 
int hierarchy_top_prediction(float *predictions, tree *hier, float thresh, int stride)
Definition: tree.c:53
float thresh
Definition: darknet.h:198
void delta_region_mask(float *truth, float *x, int n, int index, float *delta, int stride, int scale)
Definition: region_layer.c:103
float object_scale
Definition: darknet.h:190
float * biases
Definition: darknet.h:236
float temperature
Definition: darknet.h:210
int * map
Definition: darknet.h:218
int w
Definition: darknet.h:140
Definition: darknet.h:87
int n
Definition: darknet.h:142
int truths
Definition: darknet.h:139
int rescore
Definition: darknet.h:175
float h
Definition: darknet.h:520
void(* forward_gpu)(struct layer, struct network)
Definition: darknet.h:126
float * truth
Definition: darknet.h:485
void(* backward_gpu)(struct layer, struct network)
Definition: darknet.h:127
size_t * seen
Definition: darknet.h:437
void axpy_gpu(int N, float ALPHA, float *X, int INCX, float *Y, int INCY)
void(* forward)(struct layer, struct network)
Definition: darknet.h:123
int out_w
Definition: darknet.h:141
int * group
Definition: darknet.h:47
int * group_offset
Definition: darknet.h:52
void delta_region_class(float *output, float *delta, int index, int class, int classes, tree *hier, float scale, int stride, float *avg_cat, int tag)
Definition: region_layer.c:112
int out_c
Definition: darknet.h:141
void zero_objectness(layer l)
Definition: region_layer.c:497
float class_scale
Definition: darknet.h:193
int entry_index(layer l, int batch, int location, int entry)
Definition: region_layer.c:151
float w
Definition: darknet.h:520
box get_region_box(float *x, float *biases, int n, int index, int i, int j, int w, int h, int stride)
Definition: region_layer.c:76
float tisnan(float x)
Definition: region_layer.c:146
Definition: darknet.h:42
int groups
Definition: darknet.h:50
void softmax_cpu(float *input, int n, int batch, int batch_offset, int groups, int group_offset, int stride, float temp, float *output)
Definition: blas.c:324
float x
Definition: darknet.h:520
int train
Definition: darknet.h:488
float logit(float x)
Definition: region_layer.c:141
int h
Definition: darknet.h:140
float * delta
Definition: darknet.h:245
int out_h
Definition: darknet.h:141
int background
Definition: darknet.h:174
void resize_region_layer(layer *l, int w, int h)
Definition: region_layer.c:56
int inputs
Definition: darknet.h:134
void(* backward)(struct layer, struct network)
Definition: darknet.h:124
float * prob
Definition: darknet.h:526
void forward_region_layer(const layer l, network net)
Definition: region_layer.c:158
float objectness
Definition: darknet.h:528
int batch
Definition: darknet.h:131
float delta_region_box(box truth, float *x, float *biases, int n, int index, int i, int j, int w, int h, float *delta, float scale, int stride)
Definition: region_layer.c:86
float * output
Definition: darknet.h:246
int onlyforward
Definition: darknet.h:203
float mask_scale
Definition: darknet.h:192
int * group_size
Definition: darknet.h:51
void copy_gpu(int N, float *X, int INCX, float *Y, int INCY)
box bbox
Definition: darknet.h:524
void correct_region_boxes(detection *dets, int n, int w, int h, int netw, int neth, int relative)
Definition: region_layer.c:336
float * bias_updates
Definition: darknet.h:237
float box_iou(box a, box b)
Definition: box.c:179
void softmax_gpu(float *input, int n, int batch, int batch_offset, int groups, int group_offset, int stride, float temp, float *output)
int coords
Definition: darknet.h:173
int c
Definition: darknet.h:140
void activate_array(float *x, const int n, const ACTIVATION a)
Definition: activations.c:100
void softmax_tree(float *input, int spatial, int batch, int stride, float temp, float *output, tree hier)
int classes
Definition: darknet.h:172
float * mask
Definition: darknet.h:527
int softmax
Definition: darknet.h:171
LAYER_TYPE type
Definition: darknet.h:120
float * input
Definition: darknet.h:484
void activate_array_gpu(float *x, int n, ACTIVATION a)
int bias_match
Definition: darknet.h:194
float y
Definition: darknet.h:520
tree * softmax_tree
Definition: darknet.h:334
box float_to_box(float *f, int stride)
Definition: box.c:91
int outputs
Definition: darknet.h:135
float mag_array(float *a, int n)
Definition: utils.c:574
void backward_region_layer(const layer l, network net)
Definition: region_layer.c:323
float coord_scale
Definition: darknet.h:189
list classes
Definition: voc_label.py:9
void get_region_detections(layer l, int w, int h, int netw, int neth, float thresh, int *map, float tree_thresh, int relative, detection *dets)
Definition: region_layer.c:364
float get_hierarchy_probability(float *x, tree *hier, int c, int stride)
Definition: tree.c:27
void hierarchy_predictions(float *predictions, int n, tree *hier, int only_leaves, int stride)
Definition: tree.c:37
layer make_region_layer(int batch, int w, int h, int n, int classes, int coords)
Definition: region_layer.c:13
float * cost
Definition: darknet.h:222
void gradient_array_gpu(float *x, int n, ACTIVATION a, float *delta)
float noobject_scale
Definition: darknet.h:191
Definition: darknet.h:519
Definition: darknet.h:119