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

Method get_gradient_for_data

dlib/cuda/cpu_dlib.cpp:3013–3034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3011 // ------------------------------------------------------------------------------------
3012
3013 void tensor_conv::
3014 get_gradient_for_data (
3015 const bool add_to_output,
3016 const tensor& gradient_input,
3017 const tensor& filters,
3018 tensor& data_gradient
3019 )
3020 {
3021 matrix<float> temp;
3022 if (!add_to_output)
3023 data_gradient = 0;
3024 for (long n = 0; n < gradient_input.num_samples(); ++n)
3025 {
3026 auto gi = mat(gradient_input.host()+gradient_input.k()*gradient_input.nr()*gradient_input.nc()*n,
3027 gradient_input.k(),
3028 gradient_input.nr()*gradient_input.nc());
3029
3030
3031 temp = trans(gi)*mat(filters);
3032 col2img(temp, data_gradient, n, filters.nr(), filters.nc(), last_stride_y, last_stride_x, last_padding_y, last_padding_x);
3033 }
3034 }
3035
3036 // ------------------------------------------------------------------------------------
3037

Callers

nothing calls this directly

Calls 8

col2imgFunction · 0.85
matFunction · 0.70
transFunction · 0.50
num_samplesMethod · 0.45
hostMethod · 0.45
kMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45

Tested by

no test coverage detected