diff --git a/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp b/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp index 978c7da33f..f27c3d458c 100644 --- a/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp +++ b/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp @@ -51,7 +51,8 @@ LRSDPFunction::LRSDPFunction(const size_t numSparseConstraints, } template -double LRSDPFunction::Evaluate(const arma::mat& coordinates) const +double LRSDPFunction::Evaluate(const arma::mat& /* coordinates */) + const { // Note: We don't require to update the R*R^T matrix here as the current // function is only used by AugLagrangian, which do not update the coordinates diff --git a/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp index f573ce9ca2..b362d3ecce 100644 --- a/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp @@ -21,8 +21,8 @@ namespace ann /** Artificial Neural Network. */ { /** * Computes the two-dimensional convolution through fft. This class allows - * specification of the type of the border type. The convolution can be compute - * with the valid border type of the full border type (default). + * specification of the type of the border type. The convolution can be + * computed with the valid border type of the full border type (default). * * FullConvolution: returns the full two-dimensional convolution. * ValidConvolution: returns only those parts of the convolution that are @@ -40,12 +40,12 @@ class FFTConvolution /* * Perform a convolution through fft (valid mode). This method only supports * input which is even on the last dimension. In case of an odd input width, a - * user can manually pad the imput or specify the padLastDim parameter which + * user can manually pad the input or specify the padLastDim parameter which * takes care of the padding. The filter instead can have any size. When using - * the valid mode the filters has to be smaller than the input. + * the valid mode the filter has to be smaller than the input. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. */ template @@ -64,23 +64,23 @@ class FFTConvolution // Pad filter and input to the output shape. filterPadded.resize(inputPadded.n_rows, inputPadded.n_cols); - output = arma::real(ifft2(arma::fft2(inputPadded) % arma::fft2( + arma::Mat temp = arma::real(ifft2(arma::fft2(inputPadded) % arma::fft2( filterPadded))); // Extract the region of interest. We don't need to handle the padLastDim in // a special way we just cut it out from the output matrix. - output = output.submat(filter.n_rows - 1, filter.n_cols - 1, + output = temp.submat(filter.n_rows - 1, filter.n_cols - 1, input.n_rows - 1, input.n_cols - 1); } /* * Perform a convolution through fft (full mode). This method only supports * input which is even on the last dimension. In case of an odd input width, a - * user can manually pad the imput or specify the padLastDim parameter which + * user can manually pad the input or specify the padLastDim parameter which * takes care of the padding. The filter instead can have any size. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. */ template @@ -110,12 +110,12 @@ class FFTConvolution filterPadded.resize(outputRows, outputCols); // Perform FFT and IFFT - output = arma::real(ifft2(arma::fft2(inputPadded) % arma::fft2( + arma::Mat temp = arma::real(ifft2(arma::fft2(inputPadded) % arma::fft2( filterPadded))); // Extract the region of interest. We don't need to handle the padLastDim // parameter in a special way we just cut it out from the output matrix. - output = output.submat(filter.n_rows - 1, filter.n_cols - 1, + output = temp.submat(filter.n_rows - 1, filter.n_cols - 1, 2 * (filter.n_rows - 1) + input.n_rows - 1, 2 * (filter.n_cols - 1) + input.n_cols - 1); } @@ -123,12 +123,12 @@ class FFTConvolution /* * Perform a convolution through fft using 3rd order tensors. This method only * supports input which is even on the last dimension. In case of an odd input - * width, a user can manually pad the imput or specify the padLastDim + * width, a user can manually pad the input or specify the padLastDim * parameter which takes care of the padding. The filter instead can have any * size. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. */ template @@ -147,8 +147,7 @@ class FFTConvolution for (size_t i = 1; i < input.n_slices; i++) { FFTConvolution::Convolution(input.slice(i), filter.slice(i), - convOutput); - output.slice(i) = convOutput; + output.slice(i)); } } @@ -156,11 +155,11 @@ class FFTConvolution * Perform a convolution through fft using dense matrix as input and a 3rd * order tensors as filter and output. This method only supports input which * is even on the last dimension. In case of an odd input width, a user can - * manually pad the imput or specify the padLastDim parameter which takes care + * manually pad the input or specify the padLastDim parameter which takes care * of the padding. The filter instead can have any size. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. */ template @@ -179,8 +178,7 @@ class FFTConvolution for (size_t i = 1; i < filter.n_slices; i++) { FFTConvolution::Convolution(input, filter.slice(i), - convOutput); - output.slice(i) = convOutput; + output.slice(i)); } } @@ -189,7 +187,7 @@ class FFTConvolution * dense matrix as filter. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. */ template @@ -208,8 +206,7 @@ class FFTConvolution for (size_t i = 1; i < input.n_slices; i++) { FFTConvolution::Convolution(input.slice(i), filter, - convOutput); - output.slice(i) = convOutput; + output.slice(i)); } } }; // class FFTConvolution diff --git a/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp index c27225f127..90882c3b7d 100644 --- a/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp @@ -39,7 +39,7 @@ class NaiveConvolution * Perform a convolution (valid mode). * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. * @param dW Stride of filter application in the x direction. * @param dH Stride of filter application in the y direction. @@ -79,7 +79,7 @@ class NaiveConvolution * Perform a convolution (full mode). * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. * @param dW Stride of filter application in the x direction. * @param dH Stride of filter application in the y direction. @@ -111,7 +111,7 @@ class NaiveConvolution * Perform a convolution using 3rd order tensors. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. * @param dW Stride of filter application in the x direction. * @param dH Stride of filter application in the y direction. @@ -143,7 +143,7 @@ class NaiveConvolution * as filter and output. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. * @param dW Stride of filter application in the x direction. * @param dH Stride of filter application in the y direction. @@ -175,7 +175,7 @@ class NaiveConvolution * dense matrix as filter. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output Output data that contains the results of the convolution. * @param dW Stride of filter application in the x direction. * @param dH Stride of filter application in the y direction. diff --git a/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp index 7cd50470ab..8ed0a9c415 100644 --- a/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp @@ -3,7 +3,7 @@ * @author Marcus Edel * * Implementation of the convolution using the singular value decomposition to - * speeded up the computation. + * speed up the computation. * * mlpack is free software; you may redistribute it and/or modify it under the * terms of the 3-clause BSD license. You should have received a copy of the @@ -24,7 +24,7 @@ namespace ann /** Artificial Neural Network. */ { /** * Computes the two-dimensional convolution using singular value decomposition. * This class allows specification of the type of the border type. The - * convolution can be compute with the valid border type of the full border + * convolution can be computed with the valid border type of the full border * type (default). * * FullConvolution: returns the full two-dimensional convolution. @@ -87,13 +87,13 @@ class SVDConvolution NaiveConvolution::Convolution(subOutput, U.unsafe_col(0), output); + arma::Mat temp; for (size_t r = 1; r < rank; r++) { subFilter = V.unsafe_col(r) * s(r); NaiveConvolution::Convolution(input, subFilter, subOutput); - arma::Mat temp; subOutput = subOutput.t(); NaiveConvolution::Convolution(subOutput, U.unsafe_col(r), temp); @@ -134,8 +134,7 @@ class SVDConvolution for (size_t i = 1; i < input.n_slices; i++) { SVDConvolution::Convolution(input.slice(i), filter.slice(i), - convOutput); - output.slice(i) = convOutput; + output.slice(i)); } } @@ -164,8 +163,7 @@ class SVDConvolution for (size_t i = 1; i < filter.n_slices; i++) { SVDConvolution::Convolution(input, filter.slice(i), - convOutput); - output.slice(i) = convOutput; + output.slice(i)); } } @@ -194,8 +192,7 @@ class SVDConvolution for (size_t i = 1; i < input.n_slices; i++) { SVDConvolution::Convolution(input.slice(i), filter, - convOutput); - output.slice(i) = convOutput; + output.slice(i)); } } }; // class SVDConvolution diff --git a/src/mlpack/methods/ann/layer/convolution_impl.hpp b/src/mlpack/methods/ann/layer/convolution_impl.hpp index 3b01406d1b..48da43af38 100644 --- a/src/mlpack/methods/ann/layer/convolution_impl.hpp +++ b/src/mlpack/methods/ann/layer/convolution_impl.hpp @@ -171,8 +171,8 @@ void Convolution< >::Backward( const arma::Mat&& /* input */, arma::Mat&& gy, arma::Mat&& g) { - arma::cube mappedError = arma::cube(gy.memptr(), - outputWidth, outputHeight, outSize); + arma::cube mappedError(gy.memptr(), outputWidth, outputHeight, outSize, + false, false); gTemp = arma::zeros >(inputTemp.n_rows, inputTemp.n_cols, inputTemp.n_slices); @@ -265,12 +265,10 @@ void Convolution< { for (size_t i = 0; i < output.n_slices; i++) { - arma::mat subOutput = output.slice(i); - - gradientTemp.slice(s) += subOutput.submat(subOutput.n_rows / 2, - subOutput.n_cols / 2, - subOutput.n_rows / 2 + gradientTemp.n_rows - 1, - subOutput.n_cols / 2 + gradientTemp.n_cols - 1); + gradientTemp.slice(s) += output.slice(i).submat(output.n_rows / 2, + output.n_cols / 2, + output.n_rows / 2 + gradientTemp.n_rows - 1, + output.n_cols / 2 + gradientTemp.n_cols - 1); } } else diff --git a/src/mlpack/methods/decision_tree/decision_tree_impl.hpp b/src/mlpack/methods/decision_tree/decision_tree_impl.hpp index 9e9a971c4e..91a0827982 100644 --- a/src/mlpack/methods/decision_tree/decision_tree_impl.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree_impl.hpp @@ -414,7 +414,7 @@ void DecisionTree(tmpData, 0, tmpData.n_cols, tmpLabels, numClasses, weights, - minimumLeafSize); + minimumLeafSize, minimumGainSplit); } //! Train on the given weighted data. diff --git a/src/mlpack/tests/convolution_test.cpp b/src/mlpack/tests/convolution_test.cpp index a277b9cb41..739a7cae40 100644 --- a/src/mlpack/tests/convolution_test.cpp +++ b/src/mlpack/tests/convolution_test.cpp @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_SUITE(ConvolutionTest); * Implementation of the convolution function test. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output The reference output data that contains the results of the * convolution. * @@ -43,7 +43,7 @@ void Convolution2DMethodTest(const arma::mat input, arma::mat convOutput; ConvolutionFunction::Convolution(input, filter, convOutput); - // Check the outut dimension. + // Check the output dimension. bool b = (convOutput.n_rows == output.n_rows) && (convOutput.n_cols == output.n_cols); BOOST_REQUIRE_EQUAL(b, 1); @@ -59,7 +59,7 @@ void Convolution2DMethodTest(const arma::mat input, * Implementation of the convolution function test using 3rd order tensors. * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output The reference output data that contains the results of the * convolution. * @@ -91,7 +91,7 @@ void Convolution3DMethodTest(const arma::cube input, * and a 3rd order tensors as filter and output (batch modus). * * @param input Input used to perform the convolution. - * @param filter Filter used to perform the conolution. + * @param filter Filter used to perform the convolution. * @param output The reference output data that contains the results of the * convolution. * @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE(ValidConvolution2DTest) output); // Perform the convolution using singular value decomposition to - // speeded up the computation. + // speed up the computation. Convolution2DMethodTest >(input, filter, output); } @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(FullConvolution2DTest) output); // Perform the convolution using singular value decomposition to - // speeded up the computation. + // speed up the computation. Convolution2DMethodTest >(input, filter, output); } @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(ValidConvolution3DTest) filterCube, outputCube); // Perform the convolution using using the singular value decomposition to - // speeded up the computation. + // speed up the computation. Convolution3DMethodTest >(inputCube, filterCube, outputCube); } @@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(FullConvolution3DTest) filterCube, outputCube); // Perform the convolution using using the singular value decomposition to - // speeded up the computation. + // speed up the computation. Convolution3DMethodTest >(inputCube, filterCube, outputCube); } @@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(ValidConvolutionBatchTest) filterCube, outputCube); // Perform the convolution using using the singular value decomposition to - // speeded up the computation. + // speed up the computation. ConvolutionMethodBatchTest >(input, filterCube, outputCube); } @@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(FullConvolutionBatchTest) filterCube, outputCube); // Perform the convolution using using the singular value decomposition to - // speeded up the computation. + // speed up the computation. ConvolutionMethodBatchTest >(input, filterCube, outputCube); }