scheme - Racket struct error: given value instantiates a different structure type with the same name -
i'm pretty familiar racket, , many in scheme , lisp family, have no idea error, or causing it:
network-biases: contract violation; given value instantiates different structure type same name expected: network? given: (network ...) <-- omitted because useless.
heres function error (i have gist of rest):
(define (update-mini-batch net mini-batch eta) (define nabla-b (map (lambda (b) (apply grid (shape b))) (network-biases net))) (define nabla-w (map (lambda (w) (apply grid (shape w))) (network-weights net))) (define-values (nabla-b-new nabla-w-new) (foldl (lambda (lst bw) (define x (first lst)) (define y (second lst)) (define-values (nabla-b nabla-w) bw) (define-values (delta-nabla-b delta-nabla-w) (backprop net x y)) (define nabla-b-new (+/ nabla-b delta-nabla-b)) (define nabla-w-new (+/ nabla-w delta-nabla-w)) (values nabla-b-new nabla-w-new)) (values nabla-b nabla-w) mini-batch)) (struct-copy network net [biases (map (lambda (b nb) (- b (* nb (/ eta (length mini-batch))))) (network-biases net) nabla-b-new)] [weights (map (lambda (w nw) (- w (* nw (/ eta (length mini-batch))))) (network-weights net) nabla-w-new)]))
i couldn't mcve threw error, don't have 1 give.
the distilled basics of i'm trying in above function this:
- calculate new values structure's properties, , create new structure new properties.
- thanks!!
structures in racket generative. means each time
(struct network (num-layers sizes biases weights) #:transparent)
is run, new type of structure created. these named network.
the error message see due evaluating structure definition twice (and bit confusing since 2 types have same name).
i can't see anywhere in code lead (struct network ...)
being run twice. using drracket or alternative environment doesn't reset namespace?
if open "nn.rkt" , run it, see error?
Comments
Post a Comment