Skip to content

Commit

Permalink
Updating gh-pages from cfab914
Browse files Browse the repository at this point in the history
  • Loading branch information
dougalm committed Jun 27, 2023
1 parent 37fc76a commit a7efaa8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 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: 927.852 ms
Run time: 12.857 us (based on 77221 runs)</div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 1.044 s
Run time: 14.110 us (based on 69687 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: 352.796 ms
Run time: 797.400 us </div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 406.650 ms
Run time: 255.600 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: 122.998 ms
Run time: 101.300 us </div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 163.456 ms
Run time: 104.800 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: 118.397 ms
Run time: 65.723 ms (based on 31 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: 144.918 ms
Run time: 68.966 ms (based on 29 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: 203.422 ms
Run time: 139.153 ms </div></div><div class="cell"><div class="code-block"><span class="whitespace">
Compile time: 265.572 ms
Run time: 162.040 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.

0 comments on commit a7efaa8

Please sign in to comment.