Hacker News new | past | comments | ask | show | jobs | submit login

Math to Code is an interactive Python tutorial (all client-side) to teach engineers how to implement math in papers.

I was inspired to create it while taking the Fast.ai course and seeing Jeremy Howard share [0] how a "complicated" Frobenius norm equation could be implemented in a single line of Python.

Math to Code uses the Skulpt library to interpret Python in JavaScript.

It's open source here: https://github.com/vthommeret/mathtocode

I would appreciate any and all feedback!

[0] https://youtu.be/4u8FxNEDUeg?t=1390

> It's time to start reading papers. And papers look something like this, which if you're anything like me, that's terrifying. And I'm not going to lie, it's still the case when I start looking at a new paper, every single time, I think, I'm not smart enough to understand this. I just can't get past that immediate reaction. So I just look at this stuff and I go, that's not something I understand. > But then I remember, this is the Adam paper and you've all seen Adam implemented in one cell of Microsoft Excel. > 1. Even familiar stuff looks complex in a paper! > 2. Papers are important for deep learning beyond the basics, but hard to read. > 3. Learn to pronounce Greek letters.

>It's open source here: https://github.com/vthommeret/mathtocode

Any chance for a license like MIT?

I got stumped at the Frobenius norm (11/13). Everything I typed in returned this:

NotImplementedError: the 'axis' parameter is currently not supported on line 7

I used variations of: np.sqrt(m.sum(m.prod())) np.sqrt(m.sum(m2))

It's been a long time since I've taken linear algebra, so I don't remember some of these operations.

That's close, but basically you need to take the square of each element first, e.g. `m * * 2` [0]. This keeps the shape of the matrix while `m.prod()` returns a single number (multiplying each element together).

So it should look something like this: `np.sqrt((m * * 2).sum())`

Re: The error message, it looks like it's occurring because `sum` doesn't normally take any parameters and interprets the argument as an "axis" parameter — https://numpy.org/doc/1.18/reference/generated/numpy.sum.htm...

Order of operations is tricky and I could do a better job breaking it down. Still plan to add the Show Solution button but need to get some sleep :-).

In the meantime you can see all the possible solutions in the repo! https://github.com/vthommeret/mathtocode/tree/master/questio...

[0] Remove the space between the asterisks / I had to add it since HN interprets them as italics.

Nice work! Does Skulpt implement numpy, or did you write a shim to implement the necessary subset of numpy?

Thanks! Skulpt doesn't implement NumPy out of the box, but I'm using a library which is basically a shim / partial implementation of NumPy for Skulpt:


It's fairly outdated (5-years old) and doesn't implement some of the functions I wanted to use (like equality), but otherwise works pretty well.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact