mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
define activation function
This commit is contained in:
parent
a07c46c089
commit
6536a791ed
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user