From 89c26d9425f9d6970faa05e7b061cfb48cc8afac Mon Sep 17 00:00:00 2001 From: Andru Liu <90433630+WallabyLester@users.noreply.github.com> Date: Tue, 8 Oct 2024 22:03:01 -0700 Subject: [PATCH] Test of training function. --- CPP_Implementation/rbf_model_test.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CPP_Implementation/rbf_model_test.cpp b/CPP_Implementation/rbf_model_test.cpp index 48a4fa8..061da88 100644 --- a/CPP_Implementation/rbf_model_test.cpp +++ b/CPP_Implementation/rbf_model_test.cpp @@ -55,6 +55,27 @@ TEST_F(RBFModelTest, Adapt_Weights) { EXPECT_NE(updated_weight, initial_weight); } +// Test training function +TEST_F(RBFModelTest, Train_Function) { + const int numSamples = 5; + double inputs[] = { + 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0, + 3.0, 3.0, 3.0, + 4.0, 4.0, 4.0 + }; + double targets[] = {0.0, 1.0, 0.0, 1.0, 0.0}; + int numIterations = 200; + double learningRate = 0.01; + + rbf->train(inputs, targets, numSamples, numIterations, learningRate); + + for (int i = 0; i < n_centers; ++i) { + EXPECT_NE(rbf->get_weight(i), 0.0); + } +} + // Main function for running tests int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv);