Added LeakyReLu (parameter is currently hardcoded)

This commit is contained in:
lluni 2022-05-25 17:28:03 +02:00
parent f1ca0a9e54
commit a3be9daf02

View file

@ -52,4 +52,20 @@ public class ActivationFunctions {
}
return B;
}
public static SimpleMatrix LeakyReLu(SimpleMatrix A) {
SimpleMatrix B = new SimpleMatrix(A);
for (int i = 0; i < A.getNumElements(); i++) {
B.set(i, Math.max(0.001 * A.get(i), A.get(i)));
}
return B;
}
public static SimpleMatrix LeakyReLuPrime(SimpleMatrix A) {
SimpleMatrix B = new SimpleMatrix(A);
for (int i = 0; i < A.getNumElements(); i++) {
B.set(i, A.get(i) < 0 ? 0.001 : 1);
}
return B;
}
}