programlibs/Flow/demos/mlp.xtl

source · imports nn: libs/NN/src/NN.xtl; act: libs/Activations/src/Activations.xtl; flow: libs/Flow/src/Flow.xtlm

X : Float

value · line 14
X ← 4 2 r̲eshape 0.0 0.0 0.0 1.0 1.0 0.0 1.0 1.0

W1 : Float

value · line 15
W1 ← 3 3 r̲eshape 1.0 1.0 0.0 1.0 1.0 0.0 -0.5 -1.5 0.0

W2 : Float

value · line 16
W2 ← 4 2 r̲eshape -8.0 8.0 24.0 -24.0 0.0 0.0 2.0 -2.0

Y : Float

value · line 20
Y ← @ ᶠˡᵒʷp̲ipe< c"
ᶠˡᵒʷp̲ipe< expands to
({ @ →
  g1:stage ← X
  g2:stage ← { @ →
    it ← g1:stage
    it ⁿⁿd̲ense W1
  } @
  g3:stage ← ᵃᶜᵗr̲elu g2:stage
  g4:stage ← { @ →
    it ← g3:stage
    it ⁿⁿd̲ense W2
  } @
  g5:stage ← ⁿⁿs̲oftmax g4:stage
  g5:stage
} @)

z : Float

value · line 34
z ← f̲loat 1 2 3

H : Float

value · line 38
H ← @ ᶠˡᵒʷp̲ipe< c"X ▷ ᵃᶜᵗr̲elu it ⁿⁿd̲ense W1 ▹h [4 3] ▷ h"
ᶠˡᵒʷp̲ipe< expands to
({ @ →
  g8:stage ← X
  h ← { @ →
    it ← g8:stage
    ᵃᶜᵗr̲elu it ⁿⁿd̲ense W1
  } @
  _ ← { @ →
    ((s̲hape h) m̲atch r̲avel 4 c̲at 3) ? @
    "shape" ⎕S̲IGNAL "stage 2 (h): shape " c̲at (f̲ormat s̲hape h) c̲at ", expected " c̲at f̲ormat r̲avel 4 c̲at 3
  } @
  g9:stage ← h
  g9:stage
} @)