Skip to content

Standardize W1D1-W1D4 tutorial dependency setup and imports#1021

Open
cindyhfls wants to merge 35 commits into
NeuromatchAcademy:stagingfrom
cindyhfls:week1-tutorials-update
Open

Standardize W1D1-W1D4 tutorial dependency setup and imports#1021
cindyhfls wants to merge 35 commits into
NeuromatchAcademy:stagingfrom
cindyhfls:week1-tutorials-update

Conversation

@cindyhfls

@cindyhfls cindyhfls commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds tutorials/requirements_tutorials.txt listing all Colab/Kaggle pre-installed packages with minimum version bounds (Python ≥ 3.10). Intended for students running tutorials locally.
  • Adds a version check cell to each W1D1–W1D4 tutorial (Setup section): auto-installs any tutorial-specific extras not pre-installed on Colab, then prints key package versions for reproducibility and bug reports.
  • Consolidates all imports to the top-level Setup section; removes scattered import statements and duplicate !pip install calls throughout each notebook.
  • Updates the "Meet Our Lecturers" cell in W1D1_Tutorial1: flat alphabetical list of all content creators across all days with websites where available. Adds a "Past contributors" section for lecturers from days no longer in the main curriculum.

Notebooks changed

  • tutorials/requirements_tutorials.txt (new)
  • tutorials/W1D1_BasicsAndPytorch/W1D1_Tutorial1.ipynb
  • tutorials/W1D2_LinearDeepLearning/W1D2_Tutorial1.ipynb
  • tutorials/W1D2_LinearDeepLearning/W1D2_Tutorial2.ipynb
  • tutorials/W1D2_LinearDeepLearning/W1D2_Tutorial3.ipynb
  • tutorials/W1D3_MultiLayerPerceptrons/W1D3_Tutorial1.ipynb
  • tutorials/W1D3_MultiLayerPerceptrons/W1D3_Tutorial2.ipynb
  • tutorials/W1D4_Optimization/W1D4_Tutorial1.ipynb

Test plan

  • Run W1D1_Tutorial1.ipynb on Colab — verify version check cell prints correct package versions ✅
  • Run W1D2_Tutorial1.ipynb on Colab — verify version check cell and imports work
  • Spot-check that no !pip install or stray import statements remain mid-notebook in W1D2–W1D4
  • Verify pip install -r tutorials/requirements_tutorials.txt works in a clean local environment

🤖 Generated with Claude Code

cindyhfls and others added 2 commits March 29, 2026 20:27
- 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 iamzoltan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need a separate requirements file?

Comment thread tutorials/requirements_tutorials.txt Outdated
Comment on lines +1 to +23
# 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are these already included in the requirements file? why not just add missing packages there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

cindyhfls and others added 4 commits March 29, 2026 21:41
…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>
@cindyhfls cindyhfls changed the base branch from main to staging April 5, 2026 19:29
cindyhfls and others added 2 commits April 5, 2026 15:55
- 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>

@iamzoltan iamzoltan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here. and likely throughout the whole PR

Comment thread requirements.txt
Comment on lines -16 to -17
moviepy==1.0.3
imageio_ffmpeg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are you sure that we dont need the old packages you didnt include?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moviepy is not used and imageio-ffmpeg was installed and used only in W2D1

@cindyhfls

Copy link
Copy Markdown
Contributor Author

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?

@cindyhfls cindyhfls marked this pull request as draft April 10, 2026 19:32
cindyhfls and others added 4 commits April 10, 2026 15:36
- 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>
@cindyhfls cindyhfls marked this pull request as ready for review April 27, 2026 19:50
@cindyhfls

Copy link
Copy Markdown
Contributor Author

@iamzoltan do you mean this pull request? I think it's ready.

@iamzoltan iamzoltan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

small thing to fix. can you also reply to my comment about the requirements?

Comment thread tutorials/materials.yml Outdated
Comment on lines 7 to 10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you should add the bonus lecture here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

W1D1? I checked again and it does not have a bonus lecture?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

actually the materials.yml only holds links to slides, the bonus tutorial does not have slides but I will rename "lecture" to "tutorial"

@cindyhfls cindyhfls marked this pull request as draft May 1, 2026 20:46
cindyhfls and others added 5 commits May 1, 2026 18:30
- 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>
@cindyhfls cindyhfls marked this pull request as ready for review May 26, 2026 13:33
@cindyhfls cindyhfls force-pushed the week1-tutorials-update branch from 45178cf to f785c3f Compare June 9, 2026 04:46
cindyhfls and others added 2 commits June 9, 2026 01:05
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>

@iamzoltan iamzoltan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is there a commented out link id?

Comment on lines +119 to +120
"# Most packages are pre-installed on Colab/Kaggle.\n",
"# Running locally? See https://github.com/NeuromatchAcademy/course-content-dl/blob/main/requirements.txt\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why was this section added?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what are you trying to acheive?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, to point people to the requirements file

Comment thread tutorials/W1D1_BasicsAndPytorch/W1D1_Tutorial1.ipynb
"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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this outdated syllabus video cell supposed to be here still?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

Comment on lines +4180 to +4181
"# # @title Submit your feedback\n",
"# content_review(f\"{feedback_prefix}_Syllabus_Video\")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

Comment on lines +123 to +129
"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')"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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."

@iamzoltan iamzoltan Jun 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

Comment on lines +2796 to +2797
"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}$."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and here

Comment thread tutorials/materials.yml
- day: W3D2
category: Natural Language Processing
name: DL Case Study
name: DL Case Study 2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this change intentional in this PR? This PR is focused on W1 right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants