Skip to content

Commit

Permalink
fix: incorrect variable name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 30, 2024
1 parent 9b95cae commit b9f47fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
15 changes: 7 additions & 8 deletions src/bqn/nn.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ M ← +˝∘×⎉1‿∞

Minn ← {rl𝕊𝕩:
ADA ← ⟨1÷1+⋆-, ⊢×1-
B ← {tsw𝕊𝕩:
BP ← {tsw𝕊𝕩:
do ← (-ts×DA)´𝕩
𝕩×⌜¨dodo{d𝕊wly: (DA ly)×wM d}`w¨1↓⌽𝕩
𝕩×⌜¨do(do){d𝕊wly: (DA ly)×d M w}`¨´(1↓⌽)¨w𝕩
}
F ← {𝕨𝕊bw: A¨b+𝕨M w}`(¨´)
nn𝕩{fsts𝕊bw: bw-r× tsw B fs F𝕩}´˜(U1-1≠⋈·<˘2)l
E´Fnn
FP ← {𝕨𝕊bw: A¨b+𝕨M w}`(¨´)
nn𝕩{fsts𝕊bw: bw-r× tsw BP fs FP𝕩}´˜(U1-1≠⋈·<˘2)l
E´FPnn
}

L⊣×1-×⊢
nrirfdr10002.840.001
@ m ← {𝕩(⊣∾Ln)¨0 •rand.Range˜𝕩} ((ri+dr×⊢))rf
@ td ← {𝕩(⊣∾(⊣×1-×⊢)n)¨0 •rand.Range˜𝕩} ((ri+dr×⊢))rf

lm0.01‿⟨1, 10, 1Minn m
lm0.01‿⟨1, 10, 1Minn td
lm.E 2.9

)r Setplot "scatter"•Out¨ Plot´ m {ns≠⊑𝕨 ⋄ (>𝕨)˜nsns/𝕩} r
24 changes: 14 additions & 10 deletions src/nn.org
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ The original C implementation has 175 lines excluding the optimization loop. The
#+begin_src bqn :tangle ./bqn/nn.bqn
Minn ← {r‿l𝕊𝕩:
A‿DA ← ⟨1÷1+⋆∘-, ⊢×1⊸-⟩
B ← {ts‿w𝕊𝕩:
BP ← {ts‿w𝕊𝕩:
do ← (-⟜ts×DA)⊢´𝕩
𝕩×⌜¨do∾do{d𝕊w‿ly: (DA ly)×w⍉⊸M d}`w⋈¨1↓⌽𝕩
𝕩×⌜¨do∾(⊑do){d𝕊w‿ly: (DA ly)×d M w}`⋈¨´(1↓⌽)¨w‿𝕩
}
F ← {𝕨𝕊b‿w: A¨b+𝕨M w}`⟜(⋈¨´)
nn ← 𝕩{fs‿ts𝕊b‿w: b⋈w-r× ts‿w B fs F𝕩}´˜(U⚇1-⟜1∘≠⋈·<˘2⊸↕)l
E ⇐ ⊢´F⟜nn
FP ← {𝕨𝕊b‿w: A¨b+𝕨M w}`⟜(⋈¨´)
nn ← 𝕩{fs‿ts𝕊b‿w: b⋈w-r× ts‿w BP fs FP𝕩}´˜(U⚇1-⟜1∘≠⋈·<˘2⊸↕)l
E ⇐ ⊢´FP⟜nn
}
#+end_src

Expand Down Expand Up @@ -122,9 +122,8 @@ Moreover, it is not so trivial to approximate: the recurrence lacks a [[https://
the context of neural networks[fn:5]. First let's generate some reference data:

#+begin_src bqn :tangle ./bqn/nn.bqn
L ← ⊣×1⊸-×⊢
n‿ri‿rf‿dr ← 1000‿2.8‿4‿0.001
@ ⊣ m ← {𝕩(⊣∾L⍟n)¨0 •rand.Range˜≠𝕩} ↕∘⌈⌾((ri+dr×⊢)⁼)rf
@ ⊣ td ← {𝕩(⊣∾(⊣×1⊸-×⊢)⍟n)¨0 •rand.Range˜≠𝕩} ↕∘⌈⌾((ri+dr×⊢)⁼)rf
#+end_src

#+RESULTS:
Expand All @@ -133,13 +132,18 @@ the context of neural networks[fn:5]. First let's generate some reference data:
Then we can train =Minn=, and generate some approximated data with the perceptron:

#+begin_src bqn :tangle ./bqn/nn.bqn
lm ← 0.01‿⟨1, 10, 1⟩ Minn m
lm ← 0.01‿⟨1, 10, 1⟩ Minn td
≠lm.E 2.9
#+end_src

#+RESULTS:
: 1201
: 1201
: Error: Mapping: Expected equal shape prefix (1‿10 ≡ ≢𝕨, ⟨10⟩ ≡ ≢𝕩)
: at nn ← 𝕩{fs‿ts𝕊b‿w: b⋈w-r× ts‿w BP fs FP𝕩}´˜(U⚇1-⟜1∘≠⋈·<˘2⊸↕)l
: ^
: at nn ← 𝕩{fs‿ts𝕊b‿w: b⋈w-r× ts‿w BP fs FP𝕩}´˜(U⚇1-⟜1∘≠⋈·<˘2⊸↕)l
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: at lm ← 0.01‿⟨1, 10, 1⟩ Minn td
: ^^^^

Let’s see if we’ve gotten the numbers right after learning. But then again, what is a number that a man may know it[fn:6]...

Expand Down

0 comments on commit b9f47fa

Please sign in to comment.