From 289a4bdfa3143ea1e92f7b9cc622dcd6018fc37d Mon Sep 17 00:00:00 2001 From: Abhinav-Aidash <85210822+Abhinav-Aidash@users.noreply.github.com> Date: Wed, 21 Jul 2021 20:46:51 +0530 Subject: [PATCH] Update nearest_interpolation_impl.hpp --- .../methods/ann/layer/nearest_interpolation_impl.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp b/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp index 0e0a9ceab0..937e46f586 100644 --- a/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp +++ b/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp @@ -108,6 +108,16 @@ void NearestInterpolation::Backward( assert(output.n_cols == batchSize); } + if (gradient.is_empty()) + { + gradient.set_size(outRowSize * outColSize * depth, batchSize); + } + else + { + assert(gradient.n_rows == outRowSize * outColSize * depth); + assert(gradient.n_cols == batchSize); + } + assert(outRowSize >= 2); assert(outColSize >= 2);