Added LeakyReLu (parameter is currently hardcoded)
This commit is contained in:
parent
f1ca0a9e54
commit
a3be9daf02
1 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue