Skip to content

Commit 7f48c03

Browse files
author
origo
committed
Added leakyReluAlpha in toFunction
1 parent 3d1534f commit 7f48c03

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/neural-network.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ export default class NeuralNetwork {
935935
*/
936936
toFunction() {
937937
const activation = this.activation;
938+
const leakyReluAlpha = this.leakyReluAlpha;
938939
let needsVar = false;
939940
function nodeHandle(layers, layerNumber, nodeKey) {
940941
if (layerNumber === 0) {
@@ -964,7 +965,7 @@ export default class NeuralNetwork {
964965
}
965966
case 'leaky-relu': {
966967
needsVar = true;
967-
return `((v=${result.join('')})<0?0:0.01*v)`;
968+
return `((v=${result.join('')})<0?0:${leakyReluAlpha}*v)`;
968969
}
969970
case 'tanh':
970971
return `Math.tanh(${result.join('')})`;
@@ -990,4 +991,4 @@ export default class NeuralNetwork {
990991

991992
return new Function('input', `${ needsVar ? 'var v;' : '' }return ${result};`);
992993
}
993-
}
994+
}

0 commit comments

Comments
 (0)