From 831e13dc252efb60836ca747685d6764713416ed Mon Sep 17 00:00:00 2001 From: Andru Liu <90433630+WallabyLester@users.noreply.github.com> Date: Tue, 8 Oct 2024 22:02:34 -0700 Subject: [PATCH] Test for weight adaptation. --- CPP_Implementation/rbf_model_test.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CPP_Implementation/rbf_model_test.cpp b/CPP_Implementation/rbf_model_test.cpp index 700c9b2..48a4fa8 100644 --- a/CPP_Implementation/rbf_model_test.cpp +++ b/CPP_Implementation/rbf_model_test.cpp @@ -39,6 +39,22 @@ TEST_F(RBFModelTest, Predict_Output) { EXPECT_GT(output, 0.0); } +// Test adaptation of weights +TEST_F(RBFModelTest, Adapt_Weights) { + double input[] = {1.0, 2.0, 3.0}; + rbf->set_weight(0, 1.0); + double error = 0.5; + double learning_rate = 0.1; + + double initial_weight = rbf->get_weight(0); + + rbf->adapt(error, learning_rate, input); + + double updated_weight = rbf->get_weight(0); + + EXPECT_NE(updated_weight, initial_weight); +} + // Main function for running tests int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv);