diff --git a/HISTORY.md b/HISTORY.md index 3efc2e024d..0ce71722b7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -14,6 +14,7 @@ _????-??-??_ * Bump minimum Armadillo version to 10.8 (#3760). + * Adapt `NearestInterpolation` ANN layer to new Layer Inteface ## mlpack 4.4.0 _2024-05-26_ diff --git a/src/mlpack/methods/ann/layer/nearest_interpolation.hpp b/src/mlpack/methods/ann/layer/nearest_interpolation.hpp index 684e8510f1..1d9d0141a4 100644 --- a/src/mlpack/methods/ann/layer/nearest_interpolation.hpp +++ b/src/mlpack/methods/ann/layer/nearest_interpolation.hpp @@ -36,7 +36,8 @@ class NearestInterpolationType : public Layer NearestInterpolationType(); /**Create NearestInterpolation Object with the same scaleFactor along - * each dimension + * each dimension. + * NOTE: Currently this only supports 2 scaleFactors, and we plan to generalize to 1d, 2d and 3d in the future. * * @param scaleFactor Scale factors to scale each dimension by. */ diff --git a/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp b/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp index 14d2e30ff5..2969ed787a 100644 --- a/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp +++ b/src/mlpack/methods/ann/layer/nearest_interpolation_impl.hpp @@ -149,8 +149,8 @@ void NearestInterpolationType::Backward( template void NearestInterpolationType::ComputeOutputDimensions() { - if (this->inputDimensions.size() - 1 != scaleFactors.size()) { - throw std::runtime_error("Scale factors must match number of rows and columns."); + if (this->inputDimensions.size() < scaleFactors.size()) { + throw std::runtime_error("Insufficient number of input dimensions."); } this->outputDimensions = this->inputDimensions; for (size_t i = 0; i < this->InputDimensions().size()-1; i++)