Skip to content

Commit

Permalink
Fixed some exports by using the new hypers form.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMetaSchemer committed Feb 13, 2023
1 parent 1dfd752 commit e20aefd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
13 changes: 6 additions & 7 deletions main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
record
with-recording
start-logging
log-malt-reset
log-malt-fatal
log-malt-error
log-malt-warning
Expand All @@ -73,22 +74,20 @@
revise
gradient-descent
samples sampling-obj
revs alpha batch-size


naked-gradient-descent

mu
velocity-gradient-descent

beta smooth epsilon
smooth epsilon
rms-gradient-descent
adam-gradient-descent

;; Hypers
(hypers revs alpha batch-size mu beta)

;; Layer functions
line quad linear-1-1 linear plane softmax
relu k-relu recu corr k-recu
avg-cols signal-avg
signal-avg

;; Loss functions
l2-loss cross-entropy-loss kl-loss
Expand Down
11 changes: 6 additions & 5 deletions malted.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
(require "malted/N-blocks.rkt")
(require "malted/O-init.rkt")

(require "tools.rkt")

(provide dot-product-2-1 dot-product
line quad linear-1-1 linear plane softmax
avg-cols signal-avg
signal-avg

l2-loss cross-entropy-loss kl-loss
with-recording

gradient-descent revise
revs alpha batch-size
set-revs! set-alpha! set-batch-size!

(hypers revs alpha batch-size mu beta)

zeroes smooth epsilon
mu beta
set-mu! set-beta!

naked-gradient-descent
velocity-gradient-descent
Expand Down
8 changes: 1 addition & 7 deletions malted/B-layer-fns.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
(let ((expz (exp z)))
(/ expz (sum expz)))))))

(define avg-cols
(λ (t)
(λ (theta)
(let ((num-cols (ref (refr (shape t) (- (rank t) 2)) 0)))
(/ (sum-cols t) num-cols)))))

(define signal-avg
(λ (t)
(λ (theta)
Expand All @@ -54,4 +48,4 @@

(include "test/test-B-targets.rkt")

(provide line quad linear-1-1 linear plane softmax avg-cols signal-avg)
(provide line quad linear-1-1 linear plane softmax signal-avg)
4 changes: 3 additions & 1 deletion tools.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
"tools/B-random.rkt"
"tools/C-logging.rkt")

(provide hypers)

(provide with-hyper with-hypers
declare-hyper declare-hypers grid-search

random-normal random-standard-normal

record start-logging
log-malt-reset
log-malt-fatal
log-malt-error
log-malt-warning
Expand Down
12 changes: 11 additions & 1 deletion tools/C-logging.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
(list name (ρ qty)))
qty))

(define log-malt-reset
(λ ()
(log-message malt-logger 'info
(logger-name malt-logger)
"resetting"
'(reset))))

(define start-logging
(λ ([sampling-frequency 20])
(let ((log-receiver (make-log-receiver malt-logger 'debug 'malt)))
Expand All @@ -40,6 +47,8 @@
[sampling-count sampling-frequency])
(let ((data (malt-log-handler (sync log-receiver))))
(cond
((eq? data 'reset)
(loop 0.0 0.0 0.0 0.0 0.0 0 sampling-frequency))
((and data (= sampling-count 1))
(print-average (/ (sum-all d0 d1 d2 d3 d4 data) (* 6 (ρ (product (shape data))))) count)
(loop d1 d2 d3 d4 data (add1 count) sampling-frequency))
Expand Down Expand Up @@ -83,14 +92,15 @@
[topic (vector-ref log-event 3)])
(match data
(`(loss ,data) data)
(`(reset) 'reset)
(x
(fprintf (current-error-port)
"[~a] ~a: ~a~%~s~%" topic level message x)
#f)))))

(include "test/test-C-logging.rkt")

(provide record start-logging
(provide record start-logging log-malt-reset
log-malt-fatal
log-malt-error
log-malt-warning
Expand Down

0 comments on commit e20aefd

Please sign in to comment.