-
Notifications
You must be signed in to change notification settings - Fork 108
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
Dex Tutorial #443
Dex Tutorial #443
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent language introduction and persuasive literate programming, thank you!
No surprise given your history of great notebook essays:
- Tensors Considered Harmful (named tensors): http://nlp.seas.harvard.edu/NamedTensor
- The Annotated Transformer: https://nlp.seas.harvard.edu/2018/04/03/attention.html
Would you mind if I pushed a copy-editing commit to your branch? I thought that might be more efficient than leaving a bunch of small comments.
Edited: I created a PR srush#1 to your srush:tutorial
branch with some tutorial edits, in addition to merging google-research:main
into the branch. The current srush:tutorial
branch seems ~5 months outdated.
@srush: please take a look! I wanted to share as early as possible to prevent conflicting/duplicate edits.
Thanks so much Dan! I will update right away. Definitely a first draft, so I very much appreciate all the edits. Happy for any feedback. |
Sure thing! It also looks like you need to sign the Contributor License Agreement (CLA). |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
The internal link says that the email address
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@dan-zheng Errors fixed. I do want to note though that this is still a draft. I want to make most of these example run on images (maybe mnist?) to make it a bit more engaging. |
Visualization via images sounds great! |
examples/tutorial.dx
Outdated
|
||
' Next: `\`. This symbol is the lambda sigil in Dex. It is analogous to the | ||
`lambda` keyword in Python, and starts the definition of a function value | ||
(i.e. closure). In `arrSum` above: the lambda takes an argument named `acc` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically speaking it may or may not be a closure.
Idk if that kind of pedantry is useful in the tutorial though.
It might be nice to mention in this section that this can also be used to define functions, like the def
keword above.
It also might be nice to mention the symmetry between for i.
and \i.
;
though I thing that might be awkard so maybe not worth interupting flow that much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically speaking it may or may not be a closure.
Idk if that kind of pedantry is useful in the tutorial though.
Good note. From my Swift background, I use "closure" as a generic name for "function values", including both function references (trivial closures, capturing no context) and closure expressions (\x. blah x
, possibly capturing values).
It might be nice to mention in this section that this can also be used to define functions, like the
def
keword above.
I think omitting this (explanation of first-class functions, lambdas can be assigned to variables) is reasonable, given that Python programmers are familiar with it (Python also has first-class function values).
It also might be nice to mention the symmetry between
for i.
and\i.
;
though I thing that might be awkard so maybe not worth interupting flow that much.
I agree, expanding a bit on "arrays are like functions" would be neat.
We discussed a bit more about "arrays as functions" in a different thread. Sasha pointed out that "for
as a list comprehension" is more user-friendly than "arrays as function types/lambdas" (which is more programming-language-theoretic) - and this tutorial seems catered to folks coming from Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with closure. This is not supposed to be a super formal introduction, and in most informal settings lambda ≈ closure.
Tables I think. That was what the old tutorial used; iirc.
Nothing is stable, e.g. #370 like completely changed the way type classes are used and constructed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing, thanks for writing that!
examples/tutorial.dx
Outdated
|
||
' Next: `\`. This symbol is the lambda sigil in Dex. It is analogous to the | ||
`lambda` keyword in Python, and starts the definition of a function value | ||
(i.e. closure). In `arrSum` above: the lambda takes an argument named `acc` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with closure. This is not supposed to be a super formal introduction, and in most informal settings lambda ≈ closure.
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
Did another pass today to remove some sections and added some visual examples. Here's the running version: https://srush.github.io/dex-lang/tutorial.html @dougalm I love this multiple image function! @dan-zheng feel free to take over, your changes were great. I probably don't have too much more time to work on this in the next couple days. todo
I think I will defer advanced topics to a second doc. These include:
|
Thanks @srush! I'm happy to continue editing the tutorial today, making progress towards the todos you listed above. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
…h#445) The bottom padding adds unnecessary empty bottom scrolling, which slightly hurts UX.
…#444) This involves only web frontend changes via KaTeX CSS and JS: https://katex.org. I chose KaTeX over MathJax because KaTeX seems more modern, performant, and prettier.
Remove `-threaded` option to fix warning: ``` Warning: 'ghc-options: -threaded' has no effect for libraries. It should only be used for executables. ```
- Rebase on top of main branch. - Some code snippets do not yet compile due to syntax changes. This should be straightforward to fix. - Stylistic edits: use consistent terminology and voice. - Remove some second person "you" references. - Use consistent Dex and programming languages terminology and spellings. - Consistently use "array" everywhere: no mentions of "table" - Consistently use "`for` comprehension" - Consistent formatting, punctuation, heading casing (first word uppercase).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome thanks! I left a few general comments, but it looks good.
One big blocker for merging though might be the MNIST binary file. I'd be kind of reluctant to include this because of licensing issues, and git also being really bad when it comes to handling binary files in the history. Can we just include a line such as "oh btw line wget <url>
if you want to continue with the tutorial"?
Sure @apaszke I will do that and your other changes. |
Could dataset downloading be a Dex command too, via Shouldn't be much work to create a basic datasets library. I filed a feature issue for a Dex datasets library, hope that's not controversial: #458 |
Okay, think this mostly complete. Should I send a PR to the GitHub Pages branch as well or is that automated? |
da92945
to
13d9651
Compare
My opinion: I think we're happy to handle the GitHub Pages branch regeneration! Perhaps the tutorial is in a ready state for final review and merging. I'll take my final pass now. |
- Consistent space: no triple newline. - Spell out `tabXX` function names to `tableXX`. - Rename dummy `Add`` and `VSpace`` interface requirements. - Prevents clash with Prelude interfaces and requirements of the same name. - Rename title: "Dex Tutorial" → "Introduction to Dex" - Fix English typos.
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
Thanks @dan-zheng . Think everything checks from my side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delays. It's a busy week, and for some reason the email notifications still had the "[Preliminary]" prefix in your PR title, so that didn't help.
Anyway, this looks good, so I'll go ahead and merge!
rewrite all operations in terms of batched tensor interactions, but | ||
allows for a range of interactions. Put more simply, when learning | ||
MATLAB students are told repeatedly to "avoid for loops". *Dex gives | ||
for loops back*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this pitch!
An attempt at writing a Dex starter tutorial.
Goal was to start and focus on the that makes Dex unique (for / indices / type system) as opposed to starting with the syntax. Also assumes that the user is coming from python.
Open questions:
For #425