define activation function

This commit is contained in:
Krishna Vedala 2020-05-31 07:48:53 -04:00
parent a07c46c089
commit 6536a791ed

View File

@ -85,7 +85,7 @@ class adaline {
// for (int i = 0; i < x.size(); i++) y += x[i] * weights[i]; // for (int i = 0; i < x.size(); i++) y += x[i] * weights[i];
y = std::inner_product(x.begin(), x.end(), weights.begin(), y); 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; << std::endl;
} }
friend int activation(double x) { return x > 0 ? 1 : -1; }
private: private:
/** /**
* convenient function to check if input feature vector size matches the * convenient function to check if input feature vector size matches the