Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Neural Network Visualisation in Clojure. Parent comment
(defn weight-colour ([^double weight] (Color. (clamp-colour-value (Math/tanh (- weight))) (clamp-colour-value (Math/tanh weight)) 0.0)))
So when weight is 0, it's black. As the weight gets more positive, the colour gets greener, and as the weight gets more negative, the colour gets redder. clamp-colour-value makes sure the colour component doesn't go outside the interval (0,1)
tanh curve shown here: http://upload.wikimedia.org/wikipedia/commons/7/76/Sinh_cosh...
http://upload.wikimedia.org/wikipedia/commons/7/76/Sinh_cosh...
(defn weight-colour ([^double weight] (Color. (clamp-colour-value (Math/tanh (- weight))) (clamp-colour-value (Math/tanh weight)) 0.0)))
So when weight is 0, it's black. As the weight gets more positive, the colour gets greener, and as the weight gets more negative, the colour gets redder. clamp-colour-value makes sure the colour component doesn't go outside the interval (0,1)
tanh curve shown here: http://upload.wikimedia.org/wikipedia/commons/7/76/Sinh_cosh...