To do: Add LeakyRelu, Elu to ANN

This commit is contained in:
novak_99 2021-05-25 16:29:36 -07:00
parent c135e53bfc
commit 17884c6c15
3 changed files with 39 additions and 1 deletions

View File

@ -389,6 +389,24 @@ namespace MLPP{
return a; return a;
} }
std::vector<std::vector<double>> Activation::leakyReLU(std::vector<std::vector<double>> z, double c, bool deriv){
if(deriv){
std::vector<std::vector<double>> deriv;
deriv.resize(z.size());
for(int i = 0; i < z.size(); i++){
deriv[i] = leakyReLU(z[i], c, 1);
}
return deriv;
}
std::vector<std::vector<double>> a;
a.resize(z.size());
for(int i = 0; i < a.size(); i++){
a[i] = leakyReLU(z[i], c);
}
return a;
}
double Activation::ELU(double z, double c, bool deriv){ double Activation::ELU(double z, double c, bool deriv){
if (deriv){ if (deriv){
if(z <= 0){ if(z <= 0){
@ -424,6 +442,24 @@ namespace MLPP{
return a; return a;
} }
std::vector<std::vector<double>> Activation::ELU(std::vector<std::vector<double>> z, double c, bool deriv){
if(deriv){
std::vector<std::vector<double>> deriv;
deriv.resize(z.size());
for(int i = 0; i < z.size(); i++){
deriv[i] = ELU(z[i], c, 1);
}
return deriv;
}
std::vector<std::vector<double>> a;
a.resize(z.size());
for(int i = 0; i < a.size(); i++){
a[i] = ELU(z[i], c);
}
return a;
}
double Activation::SELU(double z, double lambda, double c, bool deriv){ double Activation::SELU(double z, double lambda, double c, bool deriv){
if (deriv){ if (deriv){
return ELU(z, c, 1); return ELU(z, c, 1);

View File

@ -55,9 +55,11 @@ namespace MLPP{
double leakyReLU(double z, double c, bool deriv = 0); double leakyReLU(double z, double c, bool deriv = 0);
std::vector<double> leakyReLU(std::vector<double> z, double c, bool deriv = 0); std::vector<double> leakyReLU(std::vector<double> z, double c, bool deriv = 0);
std::vector<std::vector<double>> leakyReLU(std::vector<std::vector<double>> z, double c, bool deriv = 0);
double ELU(double z, double c, bool deriv = 0); double ELU(double z, double c, bool deriv = 0);
std::vector<double> ELU(std::vector<double> z, double c, bool deriv = 0); std::vector<double> ELU(std::vector<double> z, double c, bool deriv = 0);
std::vector<std::vector<double>> ELU(std::vector<std::vector<double>> z, double c, bool deriv = 0);
double SELU(double z, double lambda, double c, bool deriv = 0); double SELU(double z, double lambda, double c, bool deriv = 0);
std::vector<double> SELU(std::vector<double> z, double lambda, double c, bool deriv = 0); std::vector<double> SELU(std::vector<double> z, double lambda, double c, bool deriv = 0);

View File

@ -9,7 +9,7 @@
// POLYMORPHIC IMPLEMENTATION OF REGRESSION CLASSES // POLYMORPHIC IMPLEMENTATION OF REGRESSION CLASSES
// EXTEND SGD/MBGD SUPPORT FOR DYN. SIZED ANN // EXTEND SGD/MBGD SUPPORT FOR DYN. SIZED ANN
// STANDARDIZE ACTIVATIONS/OPTIMIZATIONS // STANDARDIZE ACTIVATIONS/OPTIMIZATIONS
// FINISH ADDING ALL ACTIVATIONS TO ANN // ADD LEAKYRELU, ELU TO ANN
// HYPOTHESIS TESTING CLASS // HYPOTHESIS TESTING CLASS
// GAUSS MARKOV CHECKER CLASS // GAUSS MARKOV CHECKER CLASS