From 6536a791edd7a4f7a51b281bcebffe92fc5d2241 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Sun, 31 May 2020 07:48:53 -0400 Subject: [PATCH] define activation function --- machine_learning/adaline_learning.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/machine_learning/adaline_learning.cpp b/machine_learning/adaline_learning.cpp index 750341378..18c79ecbb 100644 --- a/machine_learning/adaline_learning.cpp +++ b/machine_learning/adaline_learning.cpp @@ -85,7 +85,7 @@ class adaline { // for (int i = 0; i < x.size(); i++) y += x[i] * weights[i]; y = std::inner_product(x.begin(), x.end(), weights.begin(), y); - return y >= 0 ? 1 : -1; // quantizer: apply ADALINE threshold function + return activation(y); // quantizer: apply ADALINE threshold function } /** @@ -150,6 +150,8 @@ class adaline { << std::endl; } + friend int activation(double x) { return x > 0 ? 1 : -1; } + private: /** * convenient function to check if input feature vector size matches the