Skip to content

Commit

Permalink
Updating gh-pages from 82e6de6
Browse files Browse the repository at this point in the history
  • Loading branch information
axch committed Jun 30, 2023
1 parent 6751f86 commit 00ece99
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions examples/bfgs.html
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@
</span><span class="code-span"><span class="code-span"><span class="code-span"><span class="code-span"><span class="code-span"><span class="code-span"><span class="code-span-leaf">bfgs_minimize</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>rosenbrock<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>[<span class="code-span-leaf">10<span class="symbol">.</span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">10<span class="symbol">.</span></span>]<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>eye<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>(<span class="code-span"><span class="symbol">\</span><span class="code-span-leaf">f</span><span class="symbol">.</span><span class="whitespace"> </span><span class="code-span"><span class="code-span"><span class="code-span-leaf">backtracking_line_search</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>15<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>f</span></span></span>)<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>0<span class="symbol">.</span>001<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>100</span></span><span class="whitespace">
</span></span></div><div class="result-block">BFGSresults(1.741236e-11, [0.9999971, 0.9999939], 0.0001280856, 46)</div><div class="result-block">
rosenbrock
Compile time: 1.095 s
Run time: 15.030 us (based on 64103 runs)</div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 1.009 s
Run time: 15.938 us (based on 36167 runs)</div></div><div class="cell"><div class="code-block"><span class="whitespace">
</span></div></div><div class="cell"><div class="code-block"><span class="code-span"><span class="code-span"><span class="keyword">def</span><span class="whitespace"> </span>multiclass_logistic_loss(<span class="code-span"><span class="code-span-leaf">xs</span><span class="code-span-leaf"><span class="symbol">:</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">n</span><span class="code-span-leaf"><span class="symbol">=&gt;</span></span><span class="code-span"><span class="code-span-leaf">d</span><span class="code-span-leaf"><span class="symbol">=&gt;</span></span><span class="code-span-leaf"><span class="type-name">Float</span></span></span></span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">ys</span><span class="code-span-leaf"><span class="symbol">:</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">n</span><span class="code-span-leaf"><span class="symbol">=&gt;</span></span><span class="code-span-leaf">m</span></span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">w</span><span class="code-span-leaf"><span class="symbol">:</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span">(<span class="code-span-leaf">d</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">m</span>)</span><span class="code-span-leaf"><span class="symbol">=&gt;</span></span><span class="code-span-leaf"><span class="type-name">Float</span></span></span></span>)<span class="whitespace"> </span><span class="symbol">-&gt;</span><span class="whitespace"> </span><span class="code-span-leaf"><span class="type-name">Float</span></span><span class="whitespace"> </span><span class="keyword">given</span><span class="whitespace"> </span>(<span class="code-span"><span class="code-span-leaf">n</span><span class="code-span-leaf"><span class="symbol">|</span></span><span class="code-span-leaf"><span class="type-name">Ix</span></span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">d</span><span class="code-span-leaf"><span class="symbol">|</span></span><span class="code-span-leaf"><span class="type-name">Ix</span></span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">m</span><span class="code-span-leaf"><span class="symbol">|</span></span><span class="code-span-leaf"><span class="type-name">Ix</span></span></span>)<span class="whitespace"> </span><span class="symbol">=</span><span class="whitespace">
</span><span class="code-span"><span class="code-span-leaf">w_arr</span><span class="whitespace"> </span><span class="symbol">=</span><span class="whitespace"> </span><span class="code-span"><span class="keyword">for</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">i</span><span class="code-span-leaf"><span class="symbol">:</span></span><span class="code-span-leaf">d</span></span><span class="symbol">.</span><span class="whitespace"> </span><span class="code-span"><span class="keyword">for</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">j</span><span class="code-span-leaf"><span class="symbol">:</span></span><span class="code-span-leaf">m</span></span><span class="symbol">.</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">w</span><span class="code-span">[<span class="code-span">(<span class="code-span-leaf">i</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">j</span>)</span>]</span></span></span></span></span><span class="whitespace">
</span><span class="code-span"><span class="code-span-leaf">logits</span><span class="whitespace"> </span><span class="symbol">=</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">xs</span><span class="whitespace"> </span><span class="code-span-leaf"><span class="symbol">**</span></span><span class="whitespace"> </span><span class="code-span-leaf">w_arr</span></span></span><span class="whitespace">
Expand Down
16 changes: 8 additions & 8 deletions examples/levenshtein-distance.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,17 @@
</span></div></div><div class="cell"><div class="code-block"><span class="code-span">%time<span class="whitespace">
</span><span class="code-span"><span class="code-span"><span class="code-span-leaf">levenshtein_table</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>[<span class="code-span-leaf">&#39;k&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;i&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;t&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;t&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;e&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;n&#39;</span>]<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>[<span class="code-span-leaf">&#39;s&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;i&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;t&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;t&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;i&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;n&#39;</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">&#39;g&#39;</span>]</span></span><span class="whitespace">
</span></span></div><div class="result-block">[[0, 1, 2, 3, 4, 5, 6, 7], [1, 1, 2, 3, 4, 5, 6, 7], [2, 2, 1, 2, 3, 4, 5, 6], [3, 3, 2, 1, 2, 3, 4, 5], [4, 4, 3, 2, 1, 2, 3, 4], [5, 5, 4, 3, 2, 2, 3, 4], [6, 6, 5, 4, 3, 3, 2, 3]]</div><div class="result-block">
Compile time: 414.412 ms
Run time: 288.000 us </div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 395.047 ms
Run time: 312.800 us </div></div><div class="cell"><div class="code-block"><span class="whitespace">
</span></div></div><div class="cell"><div class="prose-block"><p>The actual distance is of course just the last element of the table.</p>
</div></div><div class="cell"><div class="code-block"><span class="code-span"><span class="code-span"><span class="keyword">def</span><span class="whitespace"> </span>levenshtein(<span class="code-span"><span class="code-span-leaf">xs</span><span class="code-span-leaf"><span class="symbol">:</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">n</span><span class="code-span-leaf"><span class="symbol">=&gt;</span></span><span class="code-span-leaf">a</span></span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">ys</span><span class="code-span-leaf"><span class="symbol">:</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">m</span><span class="code-span-leaf"><span class="symbol">=&gt;</span></span><span class="code-span-leaf">a</span></span></span>)<span class="whitespace"> </span><span class="symbol">-&gt;</span><span class="whitespace"> </span><span class="code-span-leaf"><span class="type-name">Nat</span></span><span class="whitespace"> </span><span class="keyword">given</span><span class="whitespace"> </span>(<span class="code-span"><span class="code-span-leaf">n</span><span class="code-span-leaf"><span class="symbol">|</span></span><span class="code-span-leaf"><span class="type-name">Ix</span></span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">m</span><span class="code-span-leaf"><span class="symbol">|</span></span><span class="code-span-leaf"><span class="type-name">Ix</span></span></span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf">a</span><span class="code-span-leaf"><span class="symbol">|</span></span><span class="code-span-leaf"><span class="type-name">Eq</span></span></span>)<span class="whitespace"> </span><span class="symbol">=</span><span class="whitespace">
</span><span class="code-span"><span class="code-span"><span class="code-span"><span class="code-span-leaf">levenshtein_table</span><span class="code-span">(<span class="code-span-leaf">xs</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">ys</span>)</span></span><span class="code-span">[<span class="code-span-leaf">last_ix</span><span class="symbol">,</span><span class="whitespace"> </span><span class="code-span-leaf">last_ix</span>]</span></span></span></span><span class="whitespace">
</span></span></div></div><div class="cell"><div class="code-block"><span class="whitespace">
</span></div></div><div class="cell"><div class="code-block"><span class="code-span">%time<span class="whitespace">
</span><span class="code-span"><span class="code-span"><span class="code-span-leaf">levenshtein</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>(<span class="code-span"><span class="code-span-leaf">iota</span><span class="whitespace"> </span><span class="code-span-leaf"><span class="symbol">$</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"><span class="type-name">Fin</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>100</span></span></span>)<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>(<span class="code-span"><span class="code-span-leaf">iota</span><span class="whitespace"> </span><span class="code-span-leaf"><span class="symbol">$</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"><span class="type-name">Fin</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>100</span></span></span>)</span></span><span class="whitespace">
</span></span></div><div class="result-block">0</div><div class="result-block">
Compile time: 142.961 ms
Run time: 124.400 us </div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 138.500 ms
Run time: 173.900 us </div></div><div class="cell"><div class="code-block"><span class="whitespace">
</span></div></div><div class="cell"><div class="prose-block"><h2>Speed</h2>
</div></div><div class="cell"><div class="prose-block"><p>To check that we don't embarrass ourselves on performance, let's run
the Sountsov benchmark: Compute Levenshtein distances for all pairs of
Expand All @@ -396,8 +396,8 @@
</span><span class="code-span"><span class="code-span"><span class="code-span"><span class="code-span-leaf">levenshtein</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>(<span class="code-span"><span class="code-span-leaf">iota</span><span class="whitespace"> </span><span class="code-span-leaf"><span class="symbol">$</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"><span class="type-name">Fin</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>iint</span></span></span>)<span class="whitespace"> </span></span></span><span class="code-span"><span class="code-span-leaf"></span>(<span class="code-span"><span class="code-span-leaf">iota</span><span class="whitespace"> </span><span class="code-span-leaf"><span class="symbol">$</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"><span class="type-name">Fin</span></span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>jint</span></span></span>)</span></span></span></span></span></span></span><span class="whitespace">
</span></span></div><div class="result-block">
Sountsov Benchmark
Compile time: 141.047 ms
Run time: 75.917 ms (based on 27 runs)</div></div><div class="cell"><div class="code-block"><span class="code-span"><span class="code-span"><span class="code-span-leaf">sum</span><span class="code-span">(<span class="code-span"><span class="code-span-leaf">sum</span><span class="code-span">(<span class="code-span-leaf">answer</span>)</span></span>)</span></span><span class="whitespace">
Compile time: 138.800 ms
Run time: 76.939 ms (based on 26 runs)</div></div><div class="cell"><div class="code-block"><span class="code-span"><span class="code-span"><span class="code-span-leaf">sum</span><span class="code-span">(<span class="code-span"><span class="code-span-leaf">sum</span><span class="code-span">(<span class="code-span-leaf">answer</span>)</span></span>)</span></span><span class="whitespace">
</span></span></div><div class="result-block">333300</div></div><div class="cell"><div class="code-block"><span class="whitespace">
</span></div></div><div class="cell"><div class="prose-block"><p>The straightforward C++ program for this takes about 35ms on my
workstation, so Dex performance is in the right ballpark. (And we
Expand All @@ -418,8 +418,8 @@
</span></div></div><div class="cell"><div class="code-block"><span class="code-span">%time<span class="whitespace">
</span><span class="code-span"><span class="code-span-leaf">closest_word</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>&quot;hello&quot;</span></span><span class="whitespace">
</span></span></div><div class="result-block">&quot;hello&quot;</div><div class="result-block">
Compile time: 243.753 ms
Run time: 173.920 ms </div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 238.956 ms
Run time: 165.424 ms </div></div><div class="cell"><div class="code-block"><span class="whitespace">
</span></div></div><div class="cell"><div class="code-block"><span class="code-span"><span class="code-span"><span class="code-span-leaf">closest_word</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>&quot;kitttens&quot;</span></span><span class="whitespace">
</span></span></div><div class="result-block">&quot;kittens&quot;</div></div><div class="cell"><div class="code-block"><span class="code-span"><span class="code-span"><span class="code-span-leaf">closest_word</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>&quot;functor&quot;</span></span><span class="whitespace">
</span></span></div><div class="result-block">&quot;function&quot;</div></div><div class="cell"><div class="code-block"><span class="code-span"><span class="code-span"><span class="code-span-leaf">closest_word</span><span class="whitespace"> </span><span class="code-span"><span class="code-span-leaf"></span>&quot;applicative&quot;</span></span><span class="whitespace">
Expand Down
52 changes: 26 additions & 26 deletions examples/md.html

Large diffs are not rendered by default.

Loading

0 comments on commit 00ece99

Please sign in to comment.