From f4180deb9d722cdf83649eb8a50dc29dc5d76a35 Mon Sep 17 00:00:00 2001 From: akhandait Date: Sat, 7 Jul 2018 15:39:42 +0530 Subject: [PATCH] Remove pointer. --- .../methods/ann/loss_functions/reconstruction_loss.hpp | 2 +- .../ann/loss_functions/reconstruction_loss_impl.hpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp b/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp index 20d79487ac..4f46782b59 100644 --- a/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp @@ -74,7 +74,7 @@ class ReconstructionLoss private: //! Locally-stored distribution object. - DistType* dist; + DistType dist; //! Locally-stored output parameter object. OutputDataType outputParameter; diff --git a/src/mlpack/methods/ann/loss_functions/reconstruction_loss_impl.hpp b/src/mlpack/methods/ann/loss_functions/reconstruction_loss_impl.hpp index aeb72df3e4..dc24ec30f5 100644 --- a/src/mlpack/methods/ann/loss_functions/reconstruction_loss_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/reconstruction_loss_impl.hpp @@ -33,8 +33,8 @@ template double ReconstructionLoss::Forward( const InputType&& input, const TargetType&& target) { - dist = new DistType(std::move(input)); - return dist->LogProbability(std::move(target)); + dist = DistType(std::move(input)); + return -dist.LogProbability(std::move(target)); } template @@ -44,7 +44,8 @@ void ReconstructionLoss::Backward( const TargetType&& target, OutputType&& output) { - dist->LogProbBackward(std::move(target), std::move(output)); + dist.LogProbBackward(std::move(target), std::move(output)); + output = -output; } template