concepts
- forward and backward propagation
 - vanishing gradient
 - image convolution operation
 - feature map, filter/kernel
 - receptive field
 - embedding
 - translation invariance
 
| {-# LANGUAGE TypeSynonymInstances #-} | |
| data Dual d = D Float d deriving Show | |
| type Float' = Float | |
| diff :: (Dual Float' -> Dual Float') -> Float -> Float' | |
| diff f x = y' | |
| where D y y' = f (D x 1) | |
| class VectorSpace v where | |
| zero :: v | 
| import jax | |
| from jax import core | |
| from graphviz import Digraph | |
| import itertools | |
| styles = { | |
| 'const': dict(style='filled', color='goldenrod1'), | |
| 'invar': dict(color='mediumspringgreen', style='filled'), | |
| 'outvar': dict(style='filled,dashed', fillcolor='indianred1', color='black'), | 
| using ForwardDiff | |
| goo((x, y, z),) = [x^2*z, x*y*z, abs(z)-y] | |
| foo((x, y, z),) = [x^2*z, x*y*z, abs(z)-y] | |
| function foo(u::Vector{ForwardDiff.Dual{T,V,P}}) where {T,V,P} | |
| # unpack: AoS -> SoA | |
| vs = ForwardDiff.value.(u) | |
| # you can play with the dimension here, sometimes it makes sense to transpose | |
| ps = mapreduce(ForwardDiff.partials, hcat, u) | |
| # get f(vs) | |
| val = foo(vs) |