Created
September 27, 2017 07:21
-
-
Save gleenn/872bd9ef1fd766cd3f07afa2e361cd27 to your computer and use it in GitHub Desktop.
In Progress finding the value for sigmoid'(x) = 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; This doesn't work yet ;) | |
(defn sigmoid [x] (/ 1 (- 1 (Math/exp (- x))))) | |
(defn sigmoid' [x] (let [sigmoidx (sigmoid x)] (* sigmoidx (- 1 sigmoidx)))) | |
(defn bs [f ^double val ^double delta] | |
(loop [bottom -100.0 top 100.0 countdown 1000] | |
(let [middle ^double (+ bottom (/ (- top bottom) 2)) | |
f-mid ^double (f middle)] | |
(if (= 0 countdown) | |
(prn "aborting - f-mid was " f-mid) | |
(do | |
(prn bottom middle f-mid top) | |
(cond (<= (Math/abs (- f-mid val)) delta) middle | |
(< val f-mid) (recur bottom middle (dec countdown)) | |
:else (recur middle top (dec countdown)))))))) | |
(bs sigmoid 1.0 0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment