programlibs/Net/demos/xor.xtl
XOR, the network written as one line. NN's own demo builds the same two layers by hand; here the spec "2 2 relu 2 softmax" is the network, and xetal expand shows the function the macro wrote. Run with "just demo-lib Net xor"; see it with "just expand-lib Net xor".
x : Float
The four points and their classes (1: same, 2: differ).
x ← 4 2 r̲eshape 0.0 0.0 0.0 1.0 1.0 0.0 1.0 1.0
Used in: p
w1 : Float
The weights, set by hand: each layer's bias is its last row.
w1 ← 3 2 r̲eshape 1.0 1.0 1.0 1.0 0.0 -1.0
Used in: libs/Net/demos/xor.xtl:18, ᵘx̲or
ᵘx̲or : Float -> Float
The network: a function, written by the macro.
ᵘx̲or ← "2 2 relu 2 softmax" ⁿᵉᵗn̲etwork< "w1 w2"
ⁿᵉᵗn̲etwork< expands to
({ x → ⁿⁿs̲oftmax (ⁿⁿr̲elu x ⁿⁿd̲ense w1) ⁿⁿd̲ense w2 })Used in: p