From 968d38d3323bf05ed7b2ad3c2f57dee8af0a562a Mon Sep 17 00:00:00 2001 From: himanshupathak21061998 Date: Sun, 17 May 2020 06:39:46 +0530 Subject: [PATCH] Following the api of other layers --- .../ann/layer/radial_basis_function.hpp | 21 ++++++++++++++++++- .../ann/layer/radial_basis_function_impl.hpp | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/mlpack/methods/ann/layer/radial_basis_function.hpp b/src/mlpack/methods/ann/layer/radial_basis_function.hpp index 1cd541db74..81f452be7f 100644 --- a/src/mlpack/methods/ann/layer/radial_basis_function.hpp +++ b/src/mlpack/methods/ann/layer/radial_basis_function.hpp @@ -79,6 +79,21 @@ class RBF OutputDataType const& OutputParameter() const { return outputParameter; } //! Modify the output parameter. OutputDataType& OutputParameter() { return outputParameter; } + //! Get the parameters. + OutputDataType const& Parameters() const { return weights; } + //! Modify the parameters. + OutputDataType& Parameters() { return weights; } + + //! Get the input parameter. + InputDataType const& InputParameter() const { return inputParameter; } + //! Modify the input parameter. + InputDataType& InputParameter() { return inputParameter; } + + //! Get the input size. + size_t InputSize() const { return inSize; } + + //! Get the output size. + size_t OutputSize() const { return outSize; } //! Get the detla. OutputDataType const& Delta() const { return delta; } @@ -104,12 +119,16 @@ class RBF //! Locally-stored the learnable scaling factor of the shape. InputDataType sigmas; - //! Locally-stored the outeput distances of the shape. + //! Locally-stored input parameter object. + InputDataType inputParameter; + + //! Locally-stored the output distances of the shape. OutputDataType distances; //! Locally-stored weight object. OutputDataType weights; + //! Locally-stored reset parameter used to initialize the layer once. bool reset; //! Locally-stored number of input units. 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 edcaa61a61..cc9c812b8b 100644 --- a/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp +++ b/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp @@ -89,6 +89,11 @@ void RBF::serialize( ar & BOOST_SERIALIZATION_NVP(distances); ar & BOOST_SERIALIZATION_NVP(sigmas); ar & BOOST_SERIALIZATION_NVP(centres); + + // This is inefficient, but we have to allocate this memory so that + // WeightSetVisitor gets the right size. + if (Archive::is_loading::value) + weights.set_size(outSize * inSize + outSize, 1); } } // namespace ann