Download web/js/reward-stats.js from githubtailscaleduplicity342/RL-Explorer: direct link, hf CLI and curl.
- Browser
- Download file 496 Bytes
-
https://huggingface.co/spaces/githubtailscaleduplicity342/RL-Explorer/resolve/main/web/js/reward-stats.js
- Command line
-
hf download hf://spaces/githubtailscaleduplicity342/RL-Explorer/web/js/reward-stats.js
-
curl -L -o reward-stats.js https://huggingface.co/spaces/githubtailscaleduplicity342/RL-Explorer/resolve/main/web/js/reward-stats.js
496 Bytes
| // A reward's scale belongs to its environment. Retain negative and unbounded scores. | |
| export function rewardDistribution(values, bins = 10) { | |
| const xs = values.filter(Number.isFinite); | |
| const min = xs.reduce((a, x) => Math.min(a, x), 0); | |
| const max = xs.reduce((a, x) => Math.max(a, x), 1); | |
| const hist = Array(bins).fill(0); | |
| for (const x of xs) hist[Math.max(0, Math.min(bins - 1, Math.floor((x - min) / (max - min) * bins)))]++; | |
| return { hist, min, max, width: (max - min) / bins }; | |
| } | |