Skip to content
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

W2D2 Post-Course Update (Plot fix) #418

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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