diff --git a/src/mlpack/methods/ann/layer/add_impl.hpp b/src/mlpack/methods/ann/layer/add_impl.hpp index 8cd582c5ab..ff557ec42a 100644 --- a/src/mlpack/methods/ann/layer/add_impl.hpp +++ b/src/mlpack/methods/ann/layer/add_impl.hpp @@ -20,7 +20,9 @@ namespace mlpack { namespace ann /** Artificial Neural Network. */ { template -AddType::AddType() : outSize(0) +AddType::AddType() : + Layer(), + outSize(0) { // Nothing to do. } diff --git a/src/mlpack/methods/ann/layer/alpha_dropout_impl.hpp b/src/mlpack/methods/ann/layer/alpha_dropout_impl.hpp index 91a150f410..6409f57c3a 100644 --- a/src/mlpack/methods/ann/layer/alpha_dropout_impl.hpp +++ b/src/mlpack/methods/ann/layer/alpha_dropout_impl.hpp @@ -26,6 +26,7 @@ template AlphaDropoutType::AlphaDropoutType( const double ratio, const double alphaDash) : + Layer(), ratio(ratio), alphaDash(alphaDash) { diff --git a/src/mlpack/methods/ann/layer/concatenate_impl.hpp b/src/mlpack/methods/ann/layer/concatenate_impl.hpp index 8980e0c606..486431cb52 100644 --- a/src/mlpack/methods/ann/layer/concatenate_impl.hpp +++ b/src/mlpack/methods/ann/layer/concatenate_impl.hpp @@ -22,6 +22,7 @@ namespace ann /** Artificial Neural Network. */ { template ConcatenateType:: ConcatenateType(const MatType& concat) : + Layer(), concat(concat) { // Nothing to do here. diff --git a/src/mlpack/methods/ann/layer/convolution_impl.hpp b/src/mlpack/methods/ann/layer/convolution_impl.hpp index 5e4f2c618e..57731a9df5 100644 --- a/src/mlpack/methods/ann/layer/convolution_impl.hpp +++ b/src/mlpack/methods/ann/layer/convolution_impl.hpp @@ -29,7 +29,7 @@ ConvolutionType< BackwardConvolutionRule, GradientConvolutionRule, MatType ->::ConvolutionType() +>::ConvolutionType() : Layer() { // Nothing to do here. } @@ -87,6 +87,7 @@ ConvolutionType< const std::tuple& padW, const std::tuple& padH, const std::string& paddingTypeIn) : + Layer(), maps(maps), kernelWidth(kernelWidth), kernelHeight(kernelHeight), diff --git a/src/mlpack/methods/ann/layer/dropout_impl.hpp b/src/mlpack/methods/ann/layer/dropout_impl.hpp index 012de36f62..1ac7001bc4 100644 --- a/src/mlpack/methods/ann/layer/dropout_impl.hpp +++ b/src/mlpack/methods/ann/layer/dropout_impl.hpp @@ -22,6 +22,7 @@ namespace ann /** Artificial Neural Network. */ { template DropoutType::DropoutType( const double ratio) : + Layer(), ratio(ratio), scale(1.0 / (1.0 - ratio)) { diff --git a/src/mlpack/methods/ann/layer/log_softmax_impl.hpp b/src/mlpack/methods/ann/layer/log_softmax_impl.hpp index 37b2e296bd..5330bffd13 100644 --- a/src/mlpack/methods/ann/layer/log_softmax_impl.hpp +++ b/src/mlpack/methods/ann/layer/log_softmax_impl.hpp @@ -19,7 +19,8 @@ namespace mlpack { namespace ann /** Artificial Neural Network. */ { template -LogSoftMaxType::LogSoftMaxType() +LogSoftMaxType::LogSoftMaxType() : + Layer() { // Nothing to do here. } diff --git a/src/mlpack/methods/ann/layer/padding.hpp b/src/mlpack/methods/ann/layer/padding.hpp index 018a28479b..21507f9a31 100644 --- a/src/mlpack/methods/ann/layer/padding.hpp +++ b/src/mlpack/methods/ann/layer/padding.hpp @@ -36,8 +36,6 @@ class PaddingType : public Layer * @param padWRight Right padding width of the input. * @param padHTop Top padding height of the input. * @param padHBottom Bottom padding height of the input. - * @param inputWidth Width of the input. - * @param inputHeight Height of the input. */ PaddingType(const size_t padWLeft = 0, const size_t padWRight = 0, @@ -47,6 +45,18 @@ class PaddingType : public Layer //! Clone the PaddingType object. This handles polymorphism correctly. PaddingType* Clone() const { return new PaddingType(*this); } + //! Virtual destructor. + virtual ~PaddingType() { } + + //! Copy the given PaddingType. + PaddingType(const PaddingType& other); + //! Take ownership of the given PaddingType. + PaddingType(PaddingType&& other); + //! Copy the given PaddingType. + PaddingType& operator=(const PaddingType& other); + //! Take ownership of the given PaddingType. + PaddingType& operator=(PaddingType&& other); + /** * Ordinary feed forward pass of a neural network, evaluating the function * f(x) by propagating the activity forward through f. diff --git a/src/mlpack/methods/ann/layer/padding_impl.hpp b/src/mlpack/methods/ann/layer/padding_impl.hpp index 2c2811209b..97b112898b 100644 --- a/src/mlpack/methods/ann/layer/padding_impl.hpp +++ b/src/mlpack/methods/ann/layer/padding_impl.hpp @@ -25,6 +25,7 @@ PaddingType::PaddingType( const size_t padWRight, const size_t padHTop, const size_t padHBottom) : + Layer(), padWLeft(padWLeft), padWRight(padWRight), padHTop(padHTop), @@ -34,6 +35,60 @@ PaddingType::PaddingType( // Nothing to do here. } +template +PaddingType::PaddingType(const PaddingType& other) : + Layer(other), + padWLeft(other.padWLeft), + padWRight(other.padWRight), + padHTop(other.padHTop), + padHBottom(other.padHBottom), + totalInMaps(other.totalInMaps) +{ + // Nothing to do here. +} + +template +PaddingType::PaddingType(PaddingType&& other) : + Layer(std::move(other)), + padWLeft(std::move(other.padWLeft)), + padWRight(std::move(other.padWRight)), + padHTop(std::move(other.padHTop)), + padHBottom(std::move(other.padHBottom)), + totalInMaps(std::move(other.totalInMaps)) +{ + // Nothing to do here. +} + +template +PaddingType& +PaddingType::operator=(const PaddingType& other) +{ + if (this != &other) + Layer::operator=(other); + padWLeft = other.padWLeft; + padWRight = other.padWRight; + padHTop = other.padHTop; + padHBottom = other.padHBottom; + totalInMaps = other.totalInMaps; + + return *this; +} + +template +PaddingType& +PaddingType::operator=(PaddingType&& other) +{ + if (this != &other) + Layer::operator=(std::move(other)); + padWLeft = std::move(other.padWLeft); + padWRight = std::move(other.padWRight); + padHTop = std::move(other.padHTop); + padHBottom = std::move(other.padHBottom); + totalInMaps = std::move(other.totalInMaps); + + return *this; +} + template void PaddingType::Forward(const MatType& input, MatType& output) { diff --git a/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp b/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp index 55887792cd..6953baef6e 100644 --- a/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp +++ b/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp @@ -30,6 +30,7 @@ RBFType::RBFType( const size_t outSize, MatType& centres, double betas) : + Layer(), outSize(outSize), betas(betas), centres(centres) diff --git a/src/mlpack/methods/ann/layer/softmax_impl.hpp b/src/mlpack/methods/ann/layer/softmax_impl.hpp index 626dbfbffd..7cb3fcb7b7 100644 --- a/src/mlpack/methods/ann/layer/softmax_impl.hpp +++ b/src/mlpack/methods/ann/layer/softmax_impl.hpp @@ -35,7 +35,7 @@ SoftmaxType::SoftmaxType(const SoftmaxType& other) : template SoftmaxType::SoftmaxType(SoftmaxType&& other) : - Layer(other) + Layer(std::move(other)) { // Nothing to do here. }