Skip to content

Micrograd example #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2022
Merged

Micrograd example #116

merged 2 commits into from
May 5, 2022

Conversation

matdmiller
Copy link
Contributor

Added micrograd to the examples directory. This includes micrograd_ai.html and micrograd_ai.py. These files demonstrate training a basic model using the micrograd package which was created by Andrej Karpathy. This example was derived from the demo notebook in the micrograd repo (https://github.com/karpathy/micrograd/).

@philippjfr philippjfr added the tag: example Related to adding or improving examples label May 2, 2022
@matdmiller
Copy link
Contributor Author

@philippjfr
Copy link
Contributor

Love this, very, very cool! Also like the idea of using the <py-repl> for this. We should probably work out more generally whether this is how we want to structure our examples so I'll give @fpliger a chance to review and chime in.

@fpliger
Copy link
Contributor

fpliger commented May 3, 2022

@matdmiller thank you! As mentioned on Twitter, this example is really cool! I'll ask for a little patience :) since I'm currently traveling from PyCon and can't test/review with the right attention but will try to get to it tomorrow.

@fpliger fpliger added the status: ready PR that is ready for review label May 3, 2022
@matdmiller
Copy link
Contributor Author

Thanks @philippjfr and @fpliger! I'm happy to help in this small way. I'm excited to see where PyScript goes and I appreciate the all the work you're putting into it!

I love the idea of more of your examples taking advantage of <py-repl>. I think it would also be pretty awesome if your docs also took advantage of them. I think one of the best ways to learn and understand code is to be able to see a real example implementation, run it to see the output, and then be able to modify the code instantly and run it again in real time. The fast.ai library does something somewhat similar to this, in that it is written in Jupyter notebooks using the nbdev library and gives you the ability to open the doc/example notebooks directly in Google Colab and run them with very little effort. This could be even more streamlined with PyScript in that you could skip the step of opening the doc/example notebooks in Colab and wouldn't need a backend server powering it.

One other thought I had, was that it would be great if there was a way to run your examples without having to pull down the repo and run it using npm. Maybe your examples could be set up to run directly in Github Pages and directly linked from the repo. This wouldn't replace the npm option, but it would make it even easier for people to see what's possible in PyScript.

@fpliger
Copy link
Contributor

fpliger commented May 3, 2022

@matdmiller that's great feedback and suggestions! Agree on many things you mentioned... and really like the idea of using PyScript itself in the docs /cc @jezdez @kevingoldsmith )

In regards to the examples, they are also currently available in pyscript.net/examples but we need to add that info to the website and promote not more. (The native todo app there has a know bug that's is now fixed in main).

Thank you! Hope to merge this today.

without issue. Ex: intead of <code>a &gt; b</code>, you will see <code>(a).__gt__(b)</code> instead. <br>
</p>
<p>
<py-script>import js; js.document.getElementById('python-status').innerHTML = 'Python is now ready. You may proceed.'</py-script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can actually be replaced with

Element('python-status').write('Python is now ready. You may proceed.')

Copy link
Contributor

@fpliger fpliger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demo is really cool! It had a few glitches for me but all I saw was probably related to issues in PyScript itself.

@philippjfr raised a great about how we want to structure demo, etc... I'd say that it's more of a problem with us not being fully prepared with a clear process on how to contribute examples and so.

@matdmiller if you don't mind the idea that we'll have to tweak this demo later or that it may even need to be moved elsewhere, I'd lean more towards action and propose that we merge. (it's also not linked in the index file yet, which lets us work on some of the bugs that I saw and add it to the index later with a better strategy on how we add new demos)

@fpliger fpliger added status: accepted PR that has been reviewed and accepted and removed status: ready PR that is ready for review labels May 4, 2022
@matdmiller
Copy link
Contributor Author

@fpliger that sounds good! I definitely have no problems with any edits you may want or need to do. No worries about it not being linked on the index page yet either. I wasn't sure if I should do that or not. The only preference I have is that you keep some sort of attribution (I'm totally fine if the format/method of it needs to change) in this example to Andrej Karpathy who was the author of micrograd and the demo notebook I adapted for this example. Also, thanks for the tip above on the cleaner way to update the text content of the div. This is my first ever open source PR so I'm not sure if I need to do anything to modify that before this gets merged or not.

You all have been very kind and I appreciate the opportunity to contribute!

@fpliger
Copy link
Contributor

fpliger commented May 5, 2022

That's awesome! 🍻 to your first contribution to Open Source! We'll definitely keep the attribution and thank you for the kind words!

@fpliger fpliger merged commit f4ed359 into pyscript:main May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted PR that has been reviewed and accepted tag: example Related to adding or improving examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants