forked from themetaschemer/malt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nested-tensors.rkt
44 lines (30 loc) · 1.16 KB
/
nested-tensors.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#lang racket/base
(require
(except-in "nested-tensors/tensors.rkt"
rank shape reshape trefs tensor? tlen ref refr))
(require "nested-tensors/autodiff.rkt")
(require "nested-tensors/ext-ops.rkt")
(provide
len ref refr
tref tlen tmap list->tensor tensor build-tensor
ext1-ρ ext2-ρ ext1-∇ ext2-∇
dual dual? ρ κ ∇ ∇¹ (rename-out (∇ gradient-of)) map*
ext1 ext2 prim1 prim2
scalar? tensor? rank shape reshape trefs
trace-print check-dual-equal? check-ρ-∇
max-tensor-print-length make-printable
(rename-out (d+ +) (d- -) (d* *) (d/ /) (d-rectify rectify)
(d-exp exp) (d-log log) (d-expt expt) (d-sqrt sqrt) (d-sqr sqr)
(d-sum sum) (d-abs abs) (d*-2-1 *-2-1) (d-argmax argmax)
(d-max max) (d-sum-cols sum-cols) (d-correlate correlate)
(d-flatten flatten) (d-concat concat))
+-ρ --ρ *-ρ /-ρ rectify-ρ
exp-ρ log-ρ expt-ρ sqrt-ρ sqr-ρ
sum-ρ abs-ρ *-2-1-ρ argmax-ρ
max-ρ sum-cols-ρ correlate-ρ
flatten-ρ
+-0-0 --0-0 *-0-0 /-0-0 expt-0-0
exp-0 log-0 abs-0 rectify-0 sqrt-0
sum-1 argmax-1 max-1 flatten-2 concat-1-1
=-0-0 <-0-0 <=-0-0 >-0-0 >=-0-0
=-1 <-1 >-1 <=-1 >=-1 !=-1)