Skip to content
Open
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
Binary file added .DS_Store
Binary file not shown.
Binary file added segments/.DS_Store
Binary file not shown.
Binary file added segments/segment_1_intro/.DS_Store
Binary file not shown.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions segments/segment_1_intro/submissions/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Submit your version of segment 1 notebooks in following format:\
github-username__segment_1_intro.ipynb
Submit your version of segment 1 notebooks in following format:\
github-username__segment_1_intro.ipynb

Binary file added segments/segment_1_intro/submissions/example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Binary file added segments/segment_2_activation_max/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "8a730a1f",
"metadata": {},
"source": [
"# Segment 2: Activation Maximization\n",
"\n",
"*Contributed by Joyce Jiang*"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "46071dd5",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'lucent'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/var/folders/16/7cm7dl9d6qn5nkchhjc1qtpr0000gn/T/ipykernel_5287/3827666235.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mlucent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moptvis\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mrender\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparam\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mobjectives\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mlucent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodelzoo\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0minceptionv1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'lucent'"
]
}
],
"source": [
"# Load model and select target layer\n",
"import torch\n",
"import torchvision.models as models\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from lucent.optvis import render, param, objectives\n",
"from lucent.modelzoo import inceptionv1\n",
"\n",
"device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
"\n",
"model = inceptionv1(pretrained=True).to(device)\n",
"model.eval()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9945fdcf",
"metadata": {},
"outputs": [],
"source": [
"def neuron_objective(activations, channel):\n",
" return activations[:, channel].mean()\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6ebb9078",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'image_param' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/var/folders/16/7cm7dl9d6qn5nkchhjc1qtpr0000gn/T/ipykernel_5287/1980336636.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Pseudocode: Lucent-style parameterization\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mparam\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mimage_param\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m224\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'image_param' is not defined"
]
}
],
"source": [
"# Pseudocode: Lucent-style parameterization\n",
"param = image_param(size=224)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "189845e7",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

Large diffs are not rendered by default.

Binary file added segments/segment_3_dataset_images/.DS_Store
Binary file not shown.
Binary file not shown.
Loading