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

Function assign_bias_gradient

dlib/cuda/cpu_dlib.cpp:413–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411 // ----------------------------------------------------------------------------------------
412
413 void assign_bias_gradient (
414 tensor& grad,
415 const tensor& gradient_input
416 )
417 {
418 DLIB_CASSERT(
419 grad.num_samples() == 1 &&
420 gradient_input.k() == grad.k() &&
421 gradient_input.nr() == grad.nr() &&
422 gradient_input.nc() == grad.nc() &&
423 gradient_input.size() > 0);
424
425 auto out = grad.host();
426 auto in = gradient_input.host();
427
428 for (size_t i = 0; i < grad.size(); ++i)
429 out[i] = *in++;
430
431 for (long j = 1; j < gradient_input.num_samples(); ++j)
432 {
433 for (size_t i = 0; i < grad.size(); ++i)
434 out[i] += *in++;
435 }
436 }
437
438 // ------------------------------------------------------------------------------------
439

Callers 2

backwardMethod · 0.50
backwardMethod · 0.50

Calls 6

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

Tested by

no test coverage detected