Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created January 17, 2012 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/1624059 to your computer and use it in GitHub Desktop.
Save sritchie/1624059 to your computer and use it in GitHub Desktop.
(defn feature-stream []
(repeatedly #(cons 1 (repeatedly 22 rand))))
(defn label-stream []
(repeatedly #(rand-int 2)))
(defn profile-log-likelihood
[iterations batch-size]
(let [beta-seq (repeat 22 0)]
(loop [iter iterations
labels (take iterations (label-stream))
features (take iterations (feature-stream))]
(when (pos? iter)
(time (dorun (map (partial log-likelihood beta-seq)
(take batch-size labels)
(take batch-size features))))
(recur (- iter batch-size)
(drop batch-size labels)
(drop batch-size features))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment