From c90c2c5996dd21b83eb36c166e6afb82366dbb01 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 16 Nov 2010 22:58:43 -0700 Subject: [PATCH] maximum runs option in the radial basis experiment script --- scripts/radial-basis-exp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/radial-basis-exp b/scripts/radial-basis-exp index 5c632cb..9ba8db2 100755 --- a/scripts/radial-basis-exp +++ b/scripts/radial-basis-exp @@ -14,9 +14,11 @@ "Run a radial basis experiment outputting generalization data." [[n "Number of hidden radial basis neurons" 4] [k "Use k-means to position radial basis neurons" false] + [runs "optional maximum number of runs"] [eta "Value to use for eta" 0.00001]] (let [n (if (string? n) (read-string n) n) eta (if (string? eta) (read-string eta) eta) + runs (when runs (read-string runs)) x1s (map (fn [[[x1 x2] o]] x1) training) x2s (map (fn [[[x1 x2] o]] x2) training) std (sqrt (/ (+ (expt (- (apply max x1s) (apply min x1s)) 2) @@ -42,19 +44,22 @@ (doseq [[key val] [[:dimensions n] [:eta eta] [:std std] + [:runs runs] [:centers (map :t rbs)] [:starting-weights (bp :weights)]]] (println "#" key val)) - (loop [net bp count 0 last-train-err 1000 last-test-err 1000] + (loop [net bp count 0 last-train-err 1000 last-test-err 1000 runs runs] (let [train-err (rms-error net train-epic :y) test-err (rms-error net test-epic :y)] (println (format "%S\t%S\t%S" count train-err test-err)) - (when (or (< train-err last-train-err) - (< test-err last-test-err)) + (when (and (or (< train-err last-train-err) + (< test-err last-test-err)) + (or (not runs) (> runs 0))) (recur (reduce (fn [n [in out]] (second (train n in nil {:desired out}))) net train-epic) (inc count) train-err - test-err)))) + test-err + (when runs (dec runs)))))) (println "#" :ending-weights (bp :weights)))) -- 2.11.4.GIT