Transfer the value of stop_gradient for feeding data. #4831
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
图像分类模型中,当设置data_format=“NHWC”时,图像数据依旧按NCHW读进来,之后通过一个tranpose转换成NHWC格式。feed数据都是设置stop_gradient=True,直接传给conv2d,则该conv2d_grad不需要计算input_grad。插入transpose后,feed数据的stop_gradient属性没有传递给tranpose的输出变量,导致了conv2d_grad中产生了多余的计算(计算input_grad)。
这个PR将feed image的stop_gradient属性值传递给transpose的输出变量。