Skip to content

Commit

Permalink
Improve resize_bilinear CPU back-prop kernel comment
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanriach committed Nov 26, 2019
1 parent 3d77f8d commit 7fd47f1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tensorflow/core/kernels/resize_bilinear_op.cc
Expand Up @@ -309,13 +309,16 @@ struct ResizeBilinearGrad<CPUDevice, T> {

output_grad.setZero();

// Each resized pixel was computed as a weighted average of four input
// pixels. Here we find the pixels that contributed to each output pixel
// and add the corresponding coefficient to the gradient.
// resized(b, y, x, c) = top_left * (1 - y) * (1 - x)
// + top_right * (1 - y) * x
// + bottom_left * y * (1 - x)
// + bottom_right * y * x
// Each resized output pixel was computed as a weighted average of four
// input pixels. Here we find the four input pixel locations that
// contributed to each output pixel and propgate the gradient at the output
// pixel location to each of those four input pixels locations in the same
// proportions that they originally contributed to the output pixel.
// Here is the forward-propagation pseudo-code, for reference:
// resized(b, y, x, c) = top_left * (1 - y) * (1 - x)
// + top_right * (1 - y) * x
// + bottom_left * y * (1 - x)
// + bottom_right * y * x
for (Eigen::Index b = 0; b < batch; ++b) {
for (Eigen::Index y = 0; y < resized_height; ++y) {
const float in_y = scaler(y, height_scale);
Expand Down

0 comments on commit 7fd47f1

Please sign in to comment.