Turn up the temperature
One dial decides whether a model plays it safe or takes a chance.
Temperature changes how sure a model sounds. Divide every score by the temperature t, then run softmax. A small t sharpens the odds toward the top score; a big t flattens them out.
Write withTemperature(scores, t): scores is an array of numbers and t is a positive number. Return the probabilities as an array the same length as scores, adding up to 1.
Call show(probs) with your answer and the stage draws it as bars.
Example: withTemperature([0, 0], 2) returns [0.5, 0.5].
Tests you can see
withTemperature([0,0], 2)[0.5,0.5]withTemperature([1,2,3], 1)[0.09003057317038046,0.24472847105479764,0.6652409557748218]withTemperature([1,2,3], 0.5)[0.015876239976466765,0.11731042782619838,0.8668133321973349]
More tests are hidden. The server runs them all before a time counts.
The idea behind this, in a two-minute live pageCall show() while your code works and the run plays back here.
javascriptwithTemperature()
Tab indents · Cmd/Ctrl+Enter runs