Skip to content

Commit

Permalink
Merge pull request #358 from neuromatch/D8_links
Browse files Browse the repository at this point in the history
W2D4
  • Loading branch information
glibesyck authored Jul 2, 2024
2 parents 7142eb8 + 8b035f4 commit 944c330
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 126 deletions.
13 changes: 13 additions & 0 deletions tutorials/W2D4_Macrolearning/W2D4_Tutorial1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,19 @@
"display(tabs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"execution": {}
},
"outputs": [],
"source": [
"# @title Submit your feedback\n",
"content_review(f\"{feedback_prefix}_distribution_shifts_video\")"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions tutorials/W2D4_Macrolearning/W2D4_Tutorial3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@
"execution": {}
},
"source": [
"You should be able to see that the meta-loss value is decreasing. Let us look at how the first layer weight values developed throughout the first 100 epochs. Here, we project this high-dimensional weight vector into a two-dimensional space using PCA. Play with the epoch value to see the (outer) evolution of the base weights (the left plot) and see how the (inner) task-specific weights change the total weight values in the given epoch (the right plot). For clarity of visualization, we use only the first ten tasks for each epoch in the inner weight visualizations."
"You should be able to see that the meta-loss value is 0.123 for this case. Let us look at how the first layer weight values developed throughout the first 100 epochs. Here, we project this high-dimensional weight vector into a two-dimensional space using PCA. Play with the epoch value to see the (outer) evolution of the base weights (the left plot) and see how the (inner) task-specific weights change the total weight values in the given epoch (the right plot). For clarity of visualization, we use only the first ten tasks for each epoch in the inner weight visualizations."
]
},
{
Expand Down Expand Up @@ -1643,7 +1643,7 @@
},
"outputs": [],
"source": [
"# @title Make sure you execute this cell to observe the widget!\n",
"# @title Make sure you execute this cell to observe the plot!\n",
"\n",
"set_seed(42)\n",
"\n",
Expand Down
6 changes: 2 additions & 4 deletions tutorials/W2D4_Macrolearning/W2D4_Tutorial4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@
"outputs": [],
"source": [
"# @title Make sure you execute this cell to play the game!\n",
"#game()"
"game()"
]
},
{
Expand Down Expand Up @@ -996,8 +996,6 @@
"source": [
"set_seed(42)\n",
"\n",
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
"\n",
"#define environment\n",
"env = HarlowExperimentEnv()\n",
"\n",
Expand Down Expand Up @@ -1564,7 +1562,7 @@
"execution": {}
},
"source": [
"You should be able to see that the mean population score is `49.72`, and the best score is `100`. If you change `num_generations` to 800 in the previous code cell, the plot for the mean score in the population will roughly take the following form.\n",
" If you change `num_generations` to 800 in the previous code cell, the plot for the mean score in the population will roughly take the following form.\n",
"\n",
"![Picture which depicts the plot of mean scores per generation.](https://github.com/neuromatch/NeuroAI_Course/blob/main/tutorials/W2D4_Macrolearning/static/evolution.png?raw=true)\n",
"\n",
Expand Down
37 changes: 1 addition & 36 deletions tutorials/W2D4_Macrolearning/W2D4_Tutorial5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"source": [
"# @title Install and import feedback gadget\n",
"\n",
"!pip install numpy matplotlib scikit-learn ipywidgets jupyter-ui-poll torch --quiet\n",
"!pip install numpy matplotlib scikit-learn ipywidgets jupyter-ui-poll torch vibecheck --quiet\n",
"\n",
"from vibecheck import DatatopsContentReviewContainer\n",
"def content_review(notebook_section: str):\n",
Expand Down Expand Up @@ -392,41 +392,6 @@
" fid.write(r.content) # Write the downloaded content to a file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"execution": {}
},
"outputs": [],
"source": [
"# @title Set device (GPU or CPU)\n",
"\n",
"def set_device():\n",
" \"\"\"\n",
" Determines and sets the computational device for PyTorch operations based on the availability of a CUDA-capable GPU.\n",
"\n",
" Outputs:\n",
" - device (str): The device that PyTorch will use for computations ('cuda' or 'cpu'). This string can be directly used\n",
" in PyTorch operations to specify the device.\n",
" \"\"\"\n",
"\n",
" device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
" if device != \"cuda\":\n",
" print(\"GPU is not enabled in this notebook. \\n\"\n",
" \"If you want to enable it, in the menu under `Runtime` -> \\n\"\n",
" \"`Hardware accelerator.` and select `GPU` from the dropdown menu\")\n",
" else:\n",
" print(\"GPU is enabled in this notebook. \\n\"\n",
" \"If you want to disable it, in the menu under `Runtime` -> \\n\"\n",
" \"`Hardware accelerator.` and select `None` from the dropdown menu\")\n",
"\n",
" return device\n",
"\n",
"device = set_device()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
13 changes: 13 additions & 0 deletions tutorials/W2D4_Macrolearning/instructor/W2D4_Tutorial1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,19 @@
"display(tabs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"execution": {}
},
"outputs": [],
"source": [
"# @title Submit your feedback\n",
"content_review(f\"{feedback_prefix}_distribution_shifts_video\")"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions tutorials/W2D4_Macrolearning/instructor/W2D4_Tutorial3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@
"execution": {}
},
"source": [
"You should be able to see that the meta-loss value is decreasing. Let us look at how the first layer weight values developed throughout the first 100 epochs. Here, we project this high-dimensional weight vector into a two-dimensional space using PCA. Play with the epoch value to see the (outer) evolution of the base weights (the left plot) and see how the (inner) task-specific weights change the total weight values in the given epoch (the right plot). For clarity of visualization, we use only the first ten tasks for each epoch in the inner weight visualizations."
"You should be able to see that the meta-loss value is 0.123 for this case. Let us look at how the first layer weight values developed throughout the first 100 epochs. Here, we project this high-dimensional weight vector into a two-dimensional space using PCA. Play with the epoch value to see the (outer) evolution of the base weights (the left plot) and see how the (inner) task-specific weights change the total weight values in the given epoch (the right plot). For clarity of visualization, we use only the first ten tasks for each epoch in the inner weight visualizations."
]
},
{
Expand Down Expand Up @@ -1649,7 +1649,7 @@
},
"outputs": [],
"source": [
"# @title Make sure you execute this cell to observe the widget!\n",
"# @title Make sure you execute this cell to observe the plot!\n",
"\n",
"set_seed(42)\n",
"\n",
Expand Down
6 changes: 2 additions & 4 deletions tutorials/W2D4_Macrolearning/instructor/W2D4_Tutorial4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@
"outputs": [],
"source": [
"# @title Make sure you execute this cell to play the game!\n",
"#game()"
"game()"
]
},
{
Expand Down Expand Up @@ -996,8 +996,6 @@
"source": [
"set_seed(42)\n",
"\n",
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
"\n",
"#define environment\n",
"env = HarlowExperimentEnv()\n",
"\n",
Expand Down Expand Up @@ -1568,7 +1566,7 @@
"execution": {}
},
"source": [
"You should be able to see that the mean population score is `49.72`, and the best score is `100`. If you change `num_generations` to 800 in the previous code cell, the plot for the mean score in the population will roughly take the following form.\n",
" If you change `num_generations` to 800 in the previous code cell, the plot for the mean score in the population will roughly take the following form.\n",
"\n",
"![Picture which depicts the plot of mean scores per generation.](https://github.com/neuromatch/NeuroAI_Course/blob/main/tutorials/W2D4_Macrolearning/static/evolution.png?raw=true)\n",
"\n",
Expand Down
37 changes: 1 addition & 36 deletions tutorials/W2D4_Macrolearning/instructor/W2D4_Tutorial5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"source": [
"# @title Install and import feedback gadget\n",
"\n",
"!pip install numpy matplotlib scikit-learn ipywidgets jupyter-ui-poll torch --quiet\n",
"!pip install numpy matplotlib scikit-learn ipywidgets jupyter-ui-poll torch vibecheck --quiet\n",
"\n",
"from vibecheck import DatatopsContentReviewContainer\n",
"def content_review(notebook_section: str):\n",
Expand Down Expand Up @@ -392,41 +392,6 @@
" fid.write(r.content) # Write the downloaded content to a file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"execution": {}
},
"outputs": [],
"source": [
"# @title Set device (GPU or CPU)\n",
"\n",
"def set_device():\n",
" \"\"\"\n",
" Determines and sets the computational device for PyTorch operations based on the availability of a CUDA-capable GPU.\n",
"\n",
" Outputs:\n",
" - device (str): The device that PyTorch will use for computations ('cuda' or 'cpu'). This string can be directly used\n",
" in PyTorch operations to specify the device.\n",
" \"\"\"\n",
"\n",
" device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
" if device != \"cuda\":\n",
" print(\"GPU is not enabled in this notebook. \\n\"\n",
" \"If you want to enable it, in the menu under `Runtime` -> \\n\"\n",
" \"`Hardware accelerator.` and select `GPU` from the dropdown menu\")\n",
" else:\n",
" print(\"GPU is enabled in this notebook. \\n\"\n",
" \"If you want to disable it, in the menu under `Runtime` -> \\n\"\n",
" \"`Hardware accelerator.` and select `None` from the dropdown menu\")\n",
"\n",
" return device\n",
"\n",
"device = set_device()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
13 changes: 13 additions & 0 deletions tutorials/W2D4_Macrolearning/student/W2D4_Tutorial1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,19 @@
"display(tabs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"execution": {}
},
"outputs": [],
"source": [
"# @title Submit your feedback\n",
"content_review(f\"{feedback_prefix}_distribution_shifts_video\")"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions tutorials/W2D4_Macrolearning/student/W2D4_Tutorial3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@
"execution": {}
},
"source": [
"You should be able to see that the meta-loss value is decreasing. Let us look at how the first layer weight values developed throughout the first 100 epochs. Here, we project this high-dimensional weight vector into a two-dimensional space using PCA. Play with the epoch value to see the (outer) evolution of the base weights (the left plot) and see how the (inner) task-specific weights change the total weight values in the given epoch (the right plot). For clarity of visualization, we use only the first ten tasks for each epoch in the inner weight visualizations."
"You should be able to see that the meta-loss value is 0.123 for this case. Let us look at how the first layer weight values developed throughout the first 100 epochs. Here, we project this high-dimensional weight vector into a two-dimensional space using PCA. Play with the epoch value to see the (outer) evolution of the base weights (the left plot) and see how the (inner) task-specific weights change the total weight values in the given epoch (the right plot). For clarity of visualization, we use only the first ten tasks for each epoch in the inner weight visualizations."
]
},
{
Expand Down Expand Up @@ -1479,7 +1479,7 @@
},
"outputs": [],
"source": [
"# @title Make sure you execute this cell to observe the widget!\n",
"# @title Make sure you execute this cell to observe the plot!\n",
"\n",
"set_seed(42)\n",
"\n",
Expand Down
6 changes: 2 additions & 4 deletions tutorials/W2D4_Macrolearning/student/W2D4_Tutorial4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@
"outputs": [],
"source": [
"# @title Make sure you execute this cell to play the game!\n",
"#game()"
"game()"
]
},
{
Expand Down Expand Up @@ -996,8 +996,6 @@
"source": [
"set_seed(42)\n",
"\n",
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
"\n",
"#define environment\n",
"env = HarlowExperimentEnv()\n",
"\n",
Expand Down Expand Up @@ -1510,7 +1508,7 @@
"execution": {}
},
"source": [
"You should be able to see that the mean population score is `49.72`, and the best score is `100`. If you change `num_generations` to 800 in the previous code cell, the plot for the mean score in the population will roughly take the following form.\n",
" If you change `num_generations` to 800 in the previous code cell, the plot for the mean score in the population will roughly take the following form.\n",
"\n",
"![Picture which depicts the plot of mean scores per generation.](https://github.com/neuromatch/NeuroAI_Course/blob/main/tutorials/W2D4_Macrolearning/static/evolution.png?raw=true)\n",
"\n",
Expand Down
37 changes: 1 addition & 36 deletions tutorials/W2D4_Macrolearning/student/W2D4_Tutorial5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"source": [
"# @title Install and import feedback gadget\n",
"\n",
"!pip install numpy matplotlib scikit-learn ipywidgets jupyter-ui-poll torch --quiet\n",
"!pip install numpy matplotlib scikit-learn ipywidgets jupyter-ui-poll torch vibecheck --quiet\n",
"\n",
"from vibecheck import DatatopsContentReviewContainer\n",
"def content_review(notebook_section: str):\n",
Expand Down Expand Up @@ -392,41 +392,6 @@
" fid.write(r.content) # Write the downloaded content to a file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"execution": {}
},
"outputs": [],
"source": [
"# @title Set device (GPU or CPU)\n",
"\n",
"def set_device():\n",
" \"\"\"\n",
" Determines and sets the computational device for PyTorch operations based on the availability of a CUDA-capable GPU.\n",
"\n",
" Outputs:\n",
" - device (str): The device that PyTorch will use for computations ('cuda' or 'cpu'). This string can be directly used\n",
" in PyTorch operations to specify the device.\n",
" \"\"\"\n",
"\n",
" device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
" if device != \"cuda\":\n",
" print(\"GPU is not enabled in this notebook. \\n\"\n",
" \"If you want to enable it, in the menu under `Runtime` -> \\n\"\n",
" \"`Hardware accelerator.` and select `GPU` from the dropdown menu\")\n",
" else:\n",
" print(\"GPU is enabled in this notebook. \\n\"\n",
" \"If you want to disable it, in the menu under `Runtime` -> \\n\"\n",
" \"`Hardware accelerator.` and select `None` from the dropdown menu\")\n",
"\n",
" return device\n",
"\n",
"device = set_device()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 944c330

Please sign in to comment.