Standardize W1D1-W1D4 tutorial dependency setup and imports#1021
Standardize W1D1-W1D4 tutorial dependency setup and imports#1021cindyhfls wants to merge 35 commits into
Conversation
- Add version check cell to W1D1-W1D4 tutorials (prints installed package versions, points local users to requirements_tutorials.txt) - Consolidate all imports to top-level Setup section; remove scattered imports and duplicate pip installs throughout each notebook - Update W1D1 Meet Our Lecturers: flat alphabetical list of all content creators with websites, annotated by source; add Past contributors section Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
iamzoltan
left a comment
There was a problem hiding this comment.
Why do we need a separate requirements file?
| # Requirements for Neuromatch Academy Deep Learning tutorials | ||
| # These packages are pre-installed on Google Colab/Kaggle. | ||
| # For local setup: pip install -r requirements_tutorials.txt | ||
| # | ||
| # Python >= 3.10 required | ||
| # Tutorial-specific packages (e.g. transformers, diffusers, altair) are | ||
| # installed at the top of the relevant tutorial notebooks. | ||
|
|
||
| numpy>=2.0 | ||
| pandas>=2.2 | ||
| matplotlib>=3.10 | ||
| torch>=2.0 | ||
| torchvision>=0.15 | ||
| scikit-learn>=1.3 | ||
| scipy>=1.13 | ||
| Pillow>=10.0 | ||
| imageio>=2.30 | ||
| seaborn>=0.13 | ||
| nltk>=3.9 | ||
| tensorboard>=2.19 | ||
| ipywidgets>=8.0 | ||
| tqdm>=4.0 | ||
| requests>=2.31 |
There was a problem hiding this comment.
are these already included in the requirements file? why not just add missing packages there?
There was a problem hiding this comment.
It looks like the other requirements file in the main repo was for building the books and use very old versions. @bgalbraith said we might want a requirements file for people who run things locally instead of using colab (with colab a lot of packages were pre-installed).
There was a problem hiding this comment.
The only requirements file was for the whole repo. building the books actually uses a different requirements file from a different repo. We should treat this requirements file as all the dependencies you would need to run this repo.
…inks - Extract altair/paper visualization bonus section into W1D1_BonusLecture.ipynb with its own install, feedback, and imports cells; remove altair/vega_datasets from main tutorial install and imports - Add Colab GPU conservation tips callout before Section 2.4; highlight that setup cells must be rerun after runtime restart - Add bold Appendix references with Colab jump links in cells referencing tensor methods, .view() docs, and GPU usage policy - Fix commented-out imports in Section 2.5 with explanatory note Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moved `import torch` before numpy/matplotlib in T2 imports cell to match course-wide convention; removed duplicate `import torch` from set_seed helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Split W1D4_Tutorial1: sections 5–8 (non-convexity, mini-batches, adaptive methods, ethics) and bonus exercise moved to new W1D4_BonusLecture.ipynb with a self-contained setup block. Tutorial1 now covers sections 1–4 only. - Moved W2D2_Tutorial2 (DL Thinking 1 — cost functions) to W1D4_Tutorial2; renamed all "DL Thinking" text to "DL Case Study". - Updated curriculum review plan: W1D4 done items, W2D2 T2 status. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- materials.yml: move Tutorial 2 slide entry from W2D2 to W1D4; update tutorial counts (W1D4: 1→2, W2D2: 2→1) - curriculum_review_plan.md: add W1D5 flex day note to check project notebook day title consistency after restructuring Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename W2D2_ConvnetsAndDlThinking → W2D2_Convnets to reflect that
the DL Case Study tutorial has moved to W1D4
- materials.yml: update W2D2 day name to "Convnets"
- W1D4_Tutorial2: fix Colab/Kaggle badge paths, day label
("Convnets and DL Case Study" → "Optimization"), and
feedback_prefix ("W2D2_T2" → "W1D4_T2")
- curriculum_review_plan.md: mark W2D2 rename as done
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ts file per Konstantine's suggestion
iamzoltan
left a comment
There was a problem hiding this comment.
Coming closer.
We dont need to commit changes to instructor, solutions, static or students directories. We can generate those in the CI.
| "outputs": [], | ||
| "source": [ | ||
| "# @title Install dependencies\n", | ||
| "# Running locally? See tutorials/requirements_tutorials.txt\n", |
There was a problem hiding this comment.
these helper comments look wrong now
| "source": [ | ||
| "# @title Install and check dependencies\n", | ||
| "# Most packages are pre-installed on Colab/Kaggle.\n", | ||
| "# Running locally? See tutorials/requirements_tutorials.txt\n", |
There was a problem hiding this comment.
same here. and likely throughout the whole PR
| moviepy==1.0.3 | ||
| imageio_ffmpeg |
There was a problem hiding this comment.
are you sure that we dont need the old packages you didnt include?
There was a problem hiding this comment.
moviepy is not used and imageio-ffmpeg was installed and used only in W2D1
|
I will fix that. Do I need to revert the changes to the student/solution etc.? Or will they be overwritten later anyway so it's fine to keep it there? |
- Tutorial1: update stale requirements path from tutorials/requirements_tutorials.txt to GitHub URL (requirements.txt was consolidated per Konstantine's suggestion) - Tutorial2: add missing version check / install cell to Setup section Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Revert JSON formatting artifacts introduced by opening notebooks in VS Code/Jupyter: source fields changed from strings to arrays, and id field reordering. No content changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@iamzoltan do you mean this pull request? I think it's ready. |
iamzoltan
left a comment
There was a problem hiding this comment.
small thing to fix. can you also reply to my comment about the requirements?
There was a problem hiding this comment.
you should add the bonus lecture here
There was a problem hiding this comment.
W1D1? I checked again and it does not have a bonus lecture?
There was a problem hiding this comment.
wait I found it. I think it might be named "Bonus Tutorial" better instead of "Bonus Lecture"? I am screening through all bonus materials for W1 now and I will update that.
There was a problem hiding this comment.
actually the materials.yml only holds links to slides, the bonus tutorial does not have slides but I will rename "lecture" to "tutorial"
- Bonus (60 years of ML research Altair visualization) merged back into Tutorial1 before the Appendix; altair/vega_datasets added to install cell and imports cell - W1D1_Tutorial1_Bonus.ipynb deleted (content now in Tutorial1) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Revert the Tutorial1/Tutorial1_Bonus split back to the original single notebook from main. Apply only the two necessary changes: - Insert import/version check cell (with correct GitHub URL for requirements) - Mark Coding Exercises 4, 6, and 7 as *(optional)* to reduce student load Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These were separated out in the split-Tutorial1 commit but are no longer needed now that Tutorial1 is restored as a single unified notebook. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Restore upstream lecturer list (organized by week) and rename section from "Meet our content creators" to "Meet our day leads". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
45178cf to
f785c3f
Compare
Convert single-string source fields back to list-of-strings format. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
iamzoltan
left a comment
There was a problem hiding this comment.
This is almost ready. Some minor things we need to address. Good work
| "# @title Tutorial slides\n", | ||
| "from IPython.display import IFrame\n", | ||
| "link_id = \"wcjrv\"\n", | ||
| "link_id = \"dg4h7\" # link_id = \"wcjrv\"\n", |
There was a problem hiding this comment.
Why is there a commented out link id?
| "# Most packages are pre-installed on Colab/Kaggle.\n", | ||
| "# Running locally? See https://github.com/NeuromatchAcademy/course-content-dl/blob/main/requirements.txt\n", |
There was a problem hiding this comment.
Why was this section added?
There was a problem hiding this comment.
what are you trying to acheive?
There was a problem hiding this comment.
yes, to point people to the requirements file
| "for i in range(len(tab_contents)):\n", | ||
| " tabs.set_title(i, video_ids[i][0])\n", | ||
| "display(tabs)" | ||
| "# This syllabus video was outdated\n", |
There was a problem hiding this comment.
is this outdated syllabus video cell supposed to be here still?
There was a problem hiding this comment.
yes it's commented out, we don't know if Konrad gets to film the new one in time, or would you rather me just remove that cell?
| "# # @title Submit your feedback\n", | ||
| "# content_review(f\"{feedback_prefix}_Syllabus_Video\")" |
| "print('Package versions:')\n", | ||
| "for _pkg in ['numpy', 'matplotlib', 'torch']:\n", | ||
| " try:\n", | ||
| " _mod = importlib.import_module(_pkg)\n", | ||
| " print(f' {_pkg}: {getattr(_mod, \"__version__\", \"unknown\")}')\n", | ||
| " except ImportError:\n", | ||
| " print(f' {_pkg}: NOT FOUND')" |
There was a problem hiding this comment.
What are you trying to achieve with these cells?
you might want to try something like this:
import importlib.metadata
print('Package versions:')
for pkg in ['numpy', 'matplotlib', 'torch']:
try:
print(f' {pkg}: {importlib.metadata.version(pkg)}')
except importlib.metadata.PackageNotFoundError:
print(f' {pkg}: NOT FOUND')There was a problem hiding this comment.
do we have to change this to your way? I think these have a similar effect and this is througout the tutorials so I don't want to change it at this point.
| "\\end{equation}\n", | ||
| "\n", | ||
| "Pay attention to the positive sign of the update in the last equation, given the definition of $v_t$, above." | ||
| "## Coding Exercise 4 *(optional)*: Implement momentum\n\nIn this exercise you will implement the momentum update given by:\n\n\\begin{equation}\nw_{t+1} = w_t - \\eta \\nabla J(w_t) + \\beta (w_t - w_{t-1})\n\\end{equation}\n\nIt is convenient to re-express this update rule in terms of a recursion. For that, we define 'velocity' as the quantity:\n\\begin{equation}\nv_{t-1} := w_{t} - w_{t-1}\n\\end{equation}\n\nwhich leads to the two-step update rule:\n\n\\begin{equation}\nv_t = - \\eta \\nabla J(w_t) + \\beta (\\underbrace{w_t - w_{t-1}}_{v_{t-1}})\n\\end{equation}\n\n\\begin{equation}\nw_{t+1} \\leftarrow w_t + v_{t}\n\\end{equation}\n\nPay attention to the positive sign of the update in the last equation, given the definition of $v_t$, above." |
There was a problem hiding this comment.
Can you fix the layout? it should be a list of strings, not this single string
| }, | ||
| "source": [ | ||
| "## Coding Exercise 6: Implement minibatch sampling\n", | ||
| "\n", |
| "source": [ | ||
| "## Coding Exercise 7: Implement RMSprop\n", | ||
| "\n", | ||
| "In this exercise you will implement the update of the RMSprop optimizer:\n", | ||
| "\n", | ||
| "\\begin{align}\n", | ||
| "v_{t} &= \\alpha v_{t-1} + (1 - \\alpha) \\nabla J(w_t)^2 \\\\ \\\\\n", | ||
| "w_{t+1} &= w_t - \\eta \\frac{\\nabla J(w_t)}{\\sqrt{v_t + \\epsilon}}\n", | ||
| "\\end{align}\n", | ||
| "\n", | ||
| "where the non-standard operations (the division of two vectors, squaring a vector, etc.) are to be interpreted as element-wise operations, i.e., the operation is applied to each (pair of) entry(ies) of the vector(s) considered as real number(s).\n", | ||
| "\n", | ||
| "Here, the $\\epsilon$ hyperparameter provides numerical stability to the algorithm by preventing the learning rate from becoming too big when $v_t$ is small. Typically, we set $\\epsilon$ to a small default value, like $10^{-8}$." | ||
| "## Coding Exercise 7 *(optional)*: Implement RMSprop\n\nIn this exercise you will implement the update of the RMSprop optimizer:\n\n\\begin{align}\nv_{t} &= \\alpha v_{t-1} + (1 - \\alpha) \\nabla J(w_t)^2 \\\\ \\\\\nw_{t+1} &= w_t - \\eta \\frac{\\nabla J(w_t)}{\\sqrt{v_t + \\epsilon}}\n\\end{align}\n\nwhere the non-standard operations (the division of two vectors, squaring a vector, etc.) are to be interpreted as element-wise operations, i.e., the operation is applied to each (pair of) entry(ies) of the vector(s) considered as real number(s).\n\nHere, the $\\epsilon$ hyperparameter provides numerical stability to the algorithm by preventing the learning rate from becoming too big when $v_t$ is small. Typically, we set $\\epsilon$ to a small default value, like $10^{-8}$." |
| - day: W3D2 | ||
| category: Natural Language Processing | ||
| name: DL Case Study | ||
| name: DL Case Study 2 |
There was a problem hiding this comment.
is this change intentional in this PR? This PR is focused on W1 right?
There was a problem hiding this comment.
yes but I read your template and it says if there is any name mismatch in the folder it might error out. This was a patch to prevent that even though this PR was for week 1
…acter replacement by json.dump
Summary
tutorials/requirements_tutorials.txtlisting all Colab/Kaggle pre-installed packages with minimum version bounds (Python ≥ 3.10). Intended for students running tutorials locally.importstatements and duplicate!pip installcalls throughout each notebook.Notebooks changed
tutorials/requirements_tutorials.txt(new)tutorials/W1D1_BasicsAndPytorch/W1D1_Tutorial1.ipynbtutorials/W1D2_LinearDeepLearning/W1D2_Tutorial1.ipynbtutorials/W1D2_LinearDeepLearning/W1D2_Tutorial2.ipynbtutorials/W1D2_LinearDeepLearning/W1D2_Tutorial3.ipynbtutorials/W1D3_MultiLayerPerceptrons/W1D3_Tutorial1.ipynbtutorials/W1D3_MultiLayerPerceptrons/W1D3_Tutorial2.ipynbtutorials/W1D4_Optimization/W1D4_Tutorial1.ipynbTest plan
!pip installor strayimportstatements remain mid-notebook in W1D2–W1D4pip install -r tutorials/requirements_tutorials.txtworks in a clean local environment🤖 Generated with Claude Code