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