From: Parichay Kapoor Date: Fri, 26 Jun 2020 09:51:43 +0000 (+0900) Subject: [optimizer] Bug fix X-Git-Tag: accepted/tizen/unified/20200706.064221~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d01017f5729b99995f4d9e359afa5f08fa094dd;p=platform%2Fcore%2Fml%2Fnntrainer.git [optimizer] Bug fix Tensor copy constructor and copy assigment operator creates a copy of the vector This led to bug in optimizer which updated the copy of the weight than the weight itself Fixed by refernce of weight in optimizer Resolves #241 Signed-off-by: Parichay Kapoor --- diff --git a/nntrainer/src/optimizer.cpp b/nntrainer/src/optimizer.cpp index e9d686c..ff57a84 100644 --- a/nntrainer/src/optimizer.cpp +++ b/nntrainer/src/optimizer.cpp @@ -103,7 +103,7 @@ void Optimizer::apply_gradients( std::vector>::iterator w_iter, g_iter; for (w_iter = weights.begin(), g_iter = gradients.begin(); w_iter != weights.end(); ++w_iter, ++g_iter) { - Tensor x = *w_iter; + Tensor &x = *w_iter; Tensor x_grad = *g_iter; x_grad = x_grad.average();