MCPcopy Create free account
hub / github.com/davisking/dlib / assign_conv_bias_gradient

Function assign_conv_bias_gradient

dlib/cuda/cpu_dlib.cpp:440–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438 // ------------------------------------------------------------------------------------
439
440 void assign_conv_bias_gradient (
441 tensor& grad,
442 const tensor& gradient_input
443 )
444 {
445 DLIB_CASSERT(
446 grad.num_samples() == 1 &&
447 grad.k() >= 1 &&
448 grad.nr() == 1 &&
449 grad.nc() == 1 &&
450 gradient_input.k() == grad.k() &&
451 gradient_input.size() > 0 &&
452 is_same_object(grad,gradient_input) == false
453 );
454
455 auto g = grad.host();
456 auto gi = gradient_input.host();
457
458 for (long k = 0; k < gradient_input.k(); ++k)
459 g[k] = 0;
460
461 for (long n = 0; n < gradient_input.num_samples(); ++n)
462 {
463 for (long k = 0; k < gradient_input.k(); ++k)
464 {
465 for (long r = 0; r < gradient_input.nr(); ++r)
466 {
467 for (long c = 0; c < gradient_input.nc(); ++c)
468 {
469 g[k] += (*gi++);
470 }
471 }
472 }
473 }
474 }
475
476 // -----------------------------------------------------------------------------------
477

Callers 3

test_more_ops2Function · 0.50
backwardMethod · 0.50
backwardMethod · 0.50

Calls 7

is_same_objectFunction · 0.50
num_samplesMethod · 0.45
kMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45
sizeMethod · 0.45
hostMethod · 0.45

Tested by 1

test_more_ops2Function · 0.40