From 48ea047100c587baa252f83e89f847957de02ef2 Mon Sep 17 00:00:00 2001 From: dangqingqing Date: Sun, 13 Nov 2016 16:47:22 +0800 Subject: [PATCH] Bug fix in testing mode. --- paddle/gserver/layers/ConcatenateLayer.cpp | 4 +++- paddle/gserver/layers/SpatialPyramidPoolLayer.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/gserver/layers/ConcatenateLayer.cpp b/paddle/gserver/layers/ConcatenateLayer.cpp index bb6709b8df..a986ec10b4 100644 --- a/paddle/gserver/layers/ConcatenateLayer.cpp +++ b/paddle/gserver/layers/ConcatenateLayer.cpp @@ -160,7 +160,9 @@ void ConcatenateLayer2::forward(PassType passType) { size_t startCol = projCol_[i].first; size_t endCol = projCol_[i].second; projOutput_[i].value = output_.value->subColMatrix(startCol, endCol); - projOutput_[i].grad = output_.grad->subColMatrix(startCol, endCol); + if (output_.grad) { + projOutput_[i].grad = output_.grad->subColMatrix(startCol, endCol); + } } { diff --git a/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp b/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp index 582abf78c8..2fcfc8e1ae 100644 --- a/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp +++ b/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp @@ -112,7 +112,9 @@ void SpatialPyramidPoolLayer::forward(PassType passType) { size_t startCol = projCol_[i].first; size_t endCol = projCol_[i].second; projOutput_[i].value = output_.value->subColMatrix(startCol, endCol); - projOutput_[i].grad = output_.grad->subColMatrix(startCol, endCol); + if (output_.grad) { + projOutput_[i].grad = output_.grad->subColMatrix(startCol, endCol); + } } for (size_t i = 0; i < pyramidHeight_; i++) { poolProjections_[i]->forward(&getInput(0), &projOutput_[i], passType); -- GitLab