MCPcopy Create free account
hub / github.com/DFin/Neural-Network-Visualisation / softmax

Function softmax

assets/main.js:2919–2925  ·  view source on GitHub ↗
(values)

Source from the content-addressed store, hash-verified

2917}
2918
2919function softmax(values) {
2920 if (!values.length) return [];
2921 const maxVal = Math.max(...values);
2922 const exps = values.map((value) => Math.exp(value - maxVal));
2923 const sum = exps.reduce((acc, value) => acc + value, 0);
2924 return exps.map((value) => (sum === 0 ? 0 : value / sum));
2925}
2926
2927function maxAbsValue(values) {
2928 let max = 0;

Callers 1

refreshNetworkStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected