diff --git a/src/mlpack/methods/ann/layer/layer_types.hpp b/src/mlpack/methods/ann/layer/layer_types.hpp index 73c6133c64..c328f4c668 100644 --- a/src/mlpack/methods/ann/layer/layer_types.hpp +++ b/src/mlpack/methods/ann/layer/layer_types.hpp @@ -58,7 +58,7 @@ //#include //#include //#include -//#include +#include //#include //#include //#include diff --git a/src/mlpack/methods/ann/layer/radial_basis_function.hpp b/src/mlpack/methods/ann/layer/radial_basis_function.hpp index bfd89d2398..2b8f5bf7bc 100644 --- a/src/mlpack/methods/ann/layer/radial_basis_function.hpp +++ b/src/mlpack/methods/ann/layer/radial_basis_function.hpp @@ -68,6 +68,9 @@ class RBF : public Layer InputType& centres, double betas = 0); + //! Clone the LinearType object. This handles polymorphism correctly. + RBF* Clone() const { return new RBF(*this); } + /** * Ordinary feed forward pass of the radial basis function. * @@ -83,12 +86,12 @@ class RBF : public Layer const OutputType& /* gy */, OutputType& /* g */); - const std::vector& OutputDimensions() const + void ComputeOutputDimensions() { - std::vector outputDimensions(inputDimensions.size(), 1); + this->outputDimensions = std::vector(this->inputDimensions.size(), + 1); // This flattens the input. - outputDimensions[0] = outSize; - return outputDimensions; + this->outputDimensions[0] = outSize; } /** 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 5e4ffd94c1..3d8f02dd9b 100644 --- a/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp +++ b/src/mlpack/methods/ann/layer/radial_basis_function_impl.hpp @@ -2,7 +2,6 @@ * @file radial_basis_function_impl.hpp * @author Himanshu Pathak * - * * 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 * 3-clause BSD license along with mlpack. If not, see @@ -96,7 +95,7 @@ void RBF::serialize( ar(CEREAL_NVP(distances)); ar(CEREAL_NVP(centres)); - ar(CEREAL_NVP(betas); + ar(CEREAL_NVP(betas)); } } // namespace ann diff --git a/src/mlpack/methods/ann/layer/serialization.hpp b/src/mlpack/methods/ann/layer/serialization.hpp index d2184987d1..72136644af 100644 --- a/src/mlpack/methods/ann/layer/serialization.hpp +++ b/src/mlpack/methods/ann/layer/serialization.hpp @@ -125,6 +125,7 @@ CEREAL_REGISTER_TYPE(mlpack::ann::NoisyLinearType<__VA_ARGS__>); \ CEREAL_REGISTER_TYPE(mlpack::ann::ConcatenateType<__VA_ARGS__>); \ CEREAL_REGISTER_TYPE(mlpack::ann::AddType<__VA_ARGS__>); \ + CEREAL_REGISTER_TYPE(mlpack::ann::RBF<__VA_ARGS__>); \ // TODO: continue... diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt index d992ed778d..c9cf1542f0 100644 --- a/src/mlpack/tests/CMakeLists.txt +++ b/src/mlpack/tests/CMakeLists.txt @@ -35,6 +35,7 @@ add_executable(mlpack_test # facilities_test.cpp # fastmks_test.cpp feedforward_network_test.cpp + feedforward_network_2_test.cpp # gan_test.cpp # gmm_test.cpp # hmm_test.cpp diff --git a/src/mlpack/tests/custom_layer.hpp b/src/mlpack/tests/custom_layer.hpp index 593496bb50..a8ad5cf4a2 100644 --- a/src/mlpack/tests/custom_layer.hpp +++ b/src/mlpack/tests/custom_layer.hpp @@ -15,7 +15,8 @@ #include #include - +#include +#include namespace mlpack { namespace ann { diff --git a/src/mlpack/tests/feedforward_network_2_test.cpp b/src/mlpack/tests/feedforward_network_2_test.cpp index f0cfcd0672..84fdb01bcf 100644 --- a/src/mlpack/tests/feedforward_network_2_test.cpp +++ b/src/mlpack/tests/feedforward_network_2_test.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -100,8 +101,8 @@ TEST_CASE("RBFNetworkTest", "[FeedForwardNetworkTest]") kmeans.Cluster(trainData, 8, centroids); FFN > model; - model.Add >(trainData.n_rows, 8, centroids); - model.Add >(8, 3); + model.Add >(8, centroids); + model.Add(3); // RBFN neural net with MeanSquaredError. TestNetwork<>(model, trainData, trainLabels1, testData, testLabels, 10, 0.1); @@ -132,8 +133,8 @@ TEST_CASE("RBFNetworkTest", "[FeedForwardNetworkTest]") kmeans1.Cluster(dataset, 140, centroids1); FFN > model1; - model1.Add >(dataset.n_rows, 140, centroids1, 4.1); - model1.Add >(140, 2); + model1.Add >(140, centroids1, 4.1); + model1.Add(2); // RBFN neural net with MeanSquaredError. TestNetwork<>(model1, dataset, labels1, dataset, labels, 10, 0.1);