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

I get stuck at page 9 - no explanation of the prod syntax



Got it! I'm working to add a "Show solution" button, but I just published another hint for that question. Specifically, the syntax is the same as for summations "m.sum()" but with "prod" instead. Additionally, you need to to multiply each element of "m" by 3 and use parentheses appropriately — (3*m).


I also got stuck here with no way forward. (until reading here)

The explanatory text "Note that the matrix first element-wise multiplied by 3." is very unclear.

Also, looking at it from a Python novice, it is not clear we were supposed to know that the .prod() operator can act on something that is not purely a named variable, but can work on an already manipulated quantity within parentheses.

Also, and this is not your fault but of Python's, but it is not clear (or merits some explanation) why some operators take the form "operator(x)" while others behave like "x.operator" or even "x.operator()" with no argument.


Thanks for the feedback. I think I was being overly clever by trying to make the product example more complicated than just `m.prod()` similar to the `m.sum()` example, but as you mentioned I was fitting two concepts in one question — operating on an already manipulated variable in addition to the new operator.

I've simplified question 9 to just `m.prod()` from the previous solution of `(m * 3).prod()` for now.

Re: Methods vs. functions — I completely agree! I actually originally implemented Math to Code using Tensorflow.js (which was simpler than using a Python interpreter) where the syntax was:

  m.pow(2).sum().sqrt()
Vs.

  np.sqrt((m ** 2).sum())
I decided to go with NumPy + Python because I felt it would be more immediately applicable vs. just learning the Tensorflow.js syntax. Also Python allows operator overloading so you can just do `2 * m` vs. `m.mul(2)`.

PyTorch has a similarly clean syntax to Tensorflow.js and includes operator overloading, but there doesn't seem to be a PyTorch shim for Skulpt, but that would be a fun project.


also, there are functions which need to be prefixed with np - the module name, but this isn't described. So for someone who isn't quite familiar with python, this doesn't make sense.


Yeah, I had the same issue as the fellow above. I think it would be helpful if the ui displayed the result of the calculation. Debugging the std-dev example was annoying. I ended up opening a python shell so that I could see results of intermediate steps.

Also, my difficulty with numpy isn't applying functions to arrays, it's seeing __repr__ of a multi-dimensional arrays and grokking what it's showing me.

Site worked well on both my iphone and pc btw.


Agreed. Particularly because NumPy has a mix of functions and methods where you need to balance parentheses.

I'd like to more clearly show the answers / I originally didn't show what the test inputs (e.g. if square root is tested with 25, 9, and 4) so you couldn't just return 5 if 25, 3 if 9, etc... but I could display some of the test inputs and not all of them.

It definitely would be great to show the intermediate results of the calculations and for things like matrix multiplication `a.dot(b)` isn't very complicated, but it doesn't give you intuition on what's happening under the hood.

Thanks for the iPhone feedback — I tried my best to make sure it worked well on mobile. The few examples I could find of interactive Python tutorials usually involved spinning up a VM with multi-second lag for each question and textareas which were not at all mobile-optimized so I wanted to try and do something better :-).




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

Search: