On this page:
1.1 Grammar
1.2 Primitives
make-empty-hasheq
vector-fold
8.3

1 Supported Language

1.1 Grammar

Any expression that when fully expanded conforms to differentiable-expr in the grammar below is amenable to differentiation (with grad and the like). Evaluating the resulting derivative will fail unless:

  differentiable-expr = expr
  | (#%expression expr)
     
  expr = id
  | (#%plain-lambda formals expr ...+)
  | (if expr expr expr)
  | (begin expr ...+)
  | (begin0 expr expr ...)
  | 
(let-values ([(id) expr] ...)
  expr ...+)
  | 
(letrec-values ([(id) expr] ...)
  expr ...+)
  | (set! id expr)
  | (quote datum)
  | (quote-syntax datum)
  | (quote-syntax datum #:local)
  | (#%plain-app expr ...+)
  | (#%variable-reference id)
  | (#%variable-reference (#%top . id))
  | (#%variable-reference)
     
  formals = (id ...)
  | (id ...+ . id)
  | id

The grammar is a strict subset of that for fully-expanded expressions. The differences are: case-lambda, #%top and with-continuation-mark are not included, and let-values and letrec-values are restricted to binding single values. See also Limitations.

1.2 Primitives

 (require rackpropagator/primitives)
  package: rackpropagator-lib

This module is required by the rackpropagator module, and all of its exported bindings are re-provided.

The bindings below are registered as primitives when this module is instantiated. Registering a backpropagator does not affect the binding otherwise, so e.g. + below will still bind the regular Racket addition function.

*

+

-

/

<

=

>

acos

add

append

apply

asin

atan

backprop

box

build-list

build-vector

caar

cadr

car

car0

cdar

cdr

cdr0

coerce-zero

cons

cos

dot

drop

equal?

exp

expt

foldl

foldl0

hash-has-key?

hash-ref

hash-ref!

hash-set!

identity

length

list

list*

list->vector

log

make-empty-hasheq

make-list

make-vector

map

null?

primal

reverse

scale

set-box!

sin

sqrt

sub1

take

tan

unbox

unsafe-car

unsafe-cdr

values

vector

vector->immutable-vector

vector->list

vector-copy

vector-fold

vector-immutable

vector-map

vector-map!

void

Of these, the following are are not documented elsewhere (they are provided by the rackpropagator module):

Return a new mutable hash table exactly like make-hasheq, except no initialization argument can be passed (and so the resulting hash table is always empty).

procedure

(vector-fold f z v)  any/c

  f : procedure?
  z : any/c
  v : vector?
Like foldl, but for a single vector argument v (f must accept two arguments).

Example:
> (vector-fold + 0 #(1 2 3 4 5))

15