Skip to content

Commit

Permalink
Merge pull request #418 from neuromatch/W2D2-fix
Browse files Browse the repository at this point in the history
W2D2 Post-Course Update (Plot fix)
  • Loading branch information
glibesyck authored Aug 21, 2024
2 parents b96a1a5 + 0722801 commit 4913740
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 54 deletions.
23 changes: 11 additions & 12 deletions tutorials/W2D2_NeuroSymbolicMethods/W2D2_Tutorial1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,15 @@
"###################################################################\n",
"\n",
"new_objs['red^'] = new_objs['red*circle'] * ~new_objs['circle']\n",
"new_objs['circle^'] = new_objs[...] * ~new_objs[...]"
"new_objs['circle^'] = new_objs[...] * ~new_objs[...]\n",
"\n",
"new_obj_sims = np.zeros((len(new_object_names), len(new_object_names)))\n",
"\n",
"for name_idx, name in enumerate(new_object_names):\n",
" for other_idx in range(name_idx, len(new_object_names)):\n",
" new_obj_sims[name_idx, other_idx] = new_obj_sims[other_idx, name_idx] = (new_objs[name] | new_objs[new_object_names[other_idx]]).item()\n",
"\n",
"plot_similarity_matrix(new_obj_sims, new_object_names, values = True)"
]
},
{
Expand All @@ -1240,17 +1248,8 @@
"new_objs = objs\n",
"\n",
"new_objs['red^'] = new_objs['red*circle'] * ~new_objs['circle']\n",
"new_objs['circle^'] = new_objs['red*circle'] * ~new_objs['red']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {}
},
"outputs": [],
"source": [
"new_objs['circle^'] = new_objs['red*circle'] * ~new_objs['red']\n",
"\n",
"new_obj_sims = np.zeros((len(new_object_names), len(new_object_names)))\n",
"\n",
"for name_idx, name in enumerate(new_object_names):\n",
Expand Down
2 changes: 0 additions & 2 deletions tutorials/W2D2_NeuroSymbolicMethods/W2D2_Tutorial2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,6 @@
" #save loss\n",
" losses.append(np.copy(loss))\n",
"\n",
"plt.figure(figsize=(15,5))\n",
"plot_training_and_choice(losses, sims, ant_names, cons_names, action_names)"
]
},
Expand Down Expand Up @@ -1328,7 +1327,6 @@
" #save loss\n",
" losses.append(np.copy(loss))\n",
"\n",
"plt.figure(figsize=(15,5))\n",
"plot_training_and_choice(losses, sims, ant_names, cons_names, action_names)"
]
},
Expand Down
21 changes: 10 additions & 11 deletions tutorials/W2D2_NeuroSymbolicMethods/instructor/W2D2_Tutorial1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,14 @@
"new_objs['red^'] = new_objs['red*circle'] * ~new_objs['circle']\n",
"new_objs['circle^'] = new_objs[...] * ~new_objs[...]\n",
"\n",
"new_obj_sims = np.zeros((len(new_object_names), len(new_object_names)))\n",
"\n",
"for name_idx, name in enumerate(new_object_names):\n",
" for other_idx in range(name_idx, len(new_object_names)):\n",
" new_obj_sims[name_idx, other_idx] = new_obj_sims[other_idx, name_idx] = (new_objs[name] | new_objs[new_object_names[other_idx]]).item()\n",
"\n",
"plot_similarity_matrix(new_obj_sims, new_object_names, values = True)\n",
"\n",
"```"
]
},
Expand All @@ -1248,17 +1256,8 @@
"new_objs = objs\n",
"\n",
"new_objs['red^'] = new_objs['red*circle'] * ~new_objs['circle']\n",
"new_objs['circle^'] = new_objs['red*circle'] * ~new_objs['red']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {}
},
"outputs": [],
"source": [
"new_objs['circle^'] = new_objs['red*circle'] * ~new_objs['red']\n",
"\n",
"new_obj_sims = np.zeros((len(new_object_names), len(new_object_names)))\n",
"\n",
"for name_idx, name in enumerate(new_object_names):\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,6 @@
" #save loss\n",
" losses.append(np.copy(loss))\n",
"\n",
"plt.figure(figsize=(15,5))\n",
"plot_training_and_choice(losses, sims, ant_names, cons_names, action_names)\n",
"\n",
"```"
Expand Down Expand Up @@ -1346,7 +1345,6 @@
" #save loss\n",
" losses.append(np.copy(loss))\n",
"\n",
"plt.figure(figsize=(15,5))\n",
"plot_training_and_choice(losses, sims, ant_names, cons_names, action_names)"
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
new_object_names = ['red','red^','red*circle','circle','circle^']
new_objs = objs

new_objs['red^'] = new_objs['red*circle'] * ~new_objs['circle']
new_objs['circle^'] = new_objs['red*circle'] * ~new_objs['red']

new_obj_sims = np.zeros((len(new_object_names), len(new_object_names)))

for name_idx, name in enumerate(new_object_names):
for other_idx in range(name_idx, len(new_object_names)):
new_obj_sims[name_idx, other_idx] = new_obj_sims[other_idx, name_idx] = (new_objs[name] | new_objs[new_object_names[other_idx]]).item()

plot_similarity_matrix(new_obj_sims, new_object_names, values = True)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@
#save loss
losses.append(np.copy(loss))

plt.figure(figsize=(15,5))
plot_training_and_choice(losses, sims, ant_names, cons_names, action_names)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 13 additions & 18 deletions tutorials/W2D2_NeuroSymbolicMethods/student/W2D2_Tutorial1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,15 @@
"###################################################################\n",
"\n",
"new_objs['red^'] = new_objs['red*circle'] * ~new_objs['circle']\n",
"new_objs['circle^'] = new_objs[...] * ~new_objs[...]"
"new_objs['circle^'] = new_objs[...] * ~new_objs[...]\n",
"\n",
"new_obj_sims = np.zeros((len(new_object_names), len(new_object_names)))\n",
"\n",
"for name_idx, name in enumerate(new_object_names):\n",
" for other_idx in range(name_idx, len(new_object_names)):\n",
" new_obj_sims[name_idx, other_idx] = new_obj_sims[other_idx, name_idx] = (new_objs[name] | new_objs[new_object_names[other_idx]]).item()\n",
"\n",
"plot_similarity_matrix(new_obj_sims, new_object_names, values = True)"
]
},
{
Expand All @@ -1194,25 +1202,12 @@
"execution": {}
},
"source": [
"[*Click for solution*](https://github.com/neuromatch/NeuroAI_Course/tree/main/tutorials/W2D2_NeuroSymbolicMethods/solutions/W2D2_Tutorial1_Solution_f77f76dd.py)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {}
},
"outputs": [],
"source": [
"new_obj_sims = np.zeros((len(new_object_names), len(new_object_names)))\n",
"[*Click for solution*](https://github.com/neuromatch/NeuroAI_Course/tree/main/tutorials/W2D2_NeuroSymbolicMethods/solutions/W2D2_Tutorial1_Solution_9bc21529.py)\n",
"\n",
"for name_idx, name in enumerate(new_object_names):\n",
" for other_idx in range(name_idx, len(new_object_names)):\n",
" new_obj_sims[name_idx, other_idx] = new_obj_sims[other_idx, name_idx] = (new_objs[name] | new_objs[new_object_names[other_idx]]).item()\n",
"*Example output:*\n",
"\n",
"plot_similarity_matrix(new_obj_sims, new_object_names, values = True)"
"<img alt='Solution hint' align='left' width=660.0 height=577.0 src=https://raw.githubusercontent.com/neuromatch/NeuroAI_Course/main/tutorials/W2D2_NeuroSymbolicMethods/static/W2D2_Tutorial1_Solution_9bc21529_0.png>\n",
"\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,6 @@
" #save loss\n",
" losses.append(np.copy(loss))\n",
"\n",
"plt.figure(figsize=(15,5))\n",
"plot_training_and_choice(losses, sims, ant_names, cons_names, action_names)"
]
},
Expand All @@ -1220,11 +1219,11 @@
"execution": {}
},
"source": [
"[*Click for solution*](https://github.com/neuromatch/NeuroAI_Course/tree/main/tutorials/W2D2_NeuroSymbolicMethods/solutions/W2D2_Tutorial2_Solution_0606b1cc.py)\n",
"[*Click for solution*](https://github.com/neuromatch/NeuroAI_Course/tree/main/tutorials/W2D2_NeuroSymbolicMethods/solutions/W2D2_Tutorial2_Solution_adb53d43.py)\n",
"\n",
"*Example output:*\n",
"\n",
"<img alt='Solution hint' align='left' width=1475.0 height=474.0 src=https://raw.githubusercontent.com/neuromatch/NeuroAI_Course/main/tutorials/W2D2_NeuroSymbolicMethods/static/W2D2_Tutorial2_Solution_0606b1cc_0.png>\n",
"<img alt='Solution hint' align='left' width=775.0 height=574.0 src=https://raw.githubusercontent.com/neuromatch/NeuroAI_Course/main/tutorials/W2D2_NeuroSymbolicMethods/static/W2D2_Tutorial2_Solution_adb53d43_0.png>\n",
"\n"
]
},
Expand Down

0 comments on commit 4913740

Please sign in to comment.