Skip to content

Commit

Permalink
Remove erroneous text instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
adjavon committed Aug 26, 2024
1 parent 44d2bdb commit 2b3882c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
Binary file added assets/diff_class.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/same_class.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/same_class_diff_color.png
Binary file not shown.
Binary file removed assets/same_color_diff_class.png
Binary file not shown.
23 changes: 11 additions & 12 deletions solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ def visualize_color_attribution_and_counterfactual(
# %%
for idx in range(batch_size):
print("Source class:", y[idx].item())
print("Target class:", 0)
print("Target class:", target_class)
visualize_color_attribution_and_counterfactual(
attributions[idx].cpu().numpy(), x[idx].cpu().numpy(), x_fake[idx].cpu().numpy()
)
Expand All @@ -980,6 +980,16 @@ def visualize_color_attribution_and_counterfactual(
# </ul>
# </div>
# %% [markdown]
# By now you will have hopefully noticed that it isn't the exact color of the image that determines its class, but that two images with a very similar color can be of different classes!
#
# Here are two examples of image-counterfactual-attribution triplets.
# You'll notice that they are *very* similar in every way! But one set is different classes, and one set is the same class!
#
# ![same_class](assets/same_class.png)
# ![diff_class](assets/diff_class.png)
#
# We are missing a crucial step of the explanation pipeline: a quantification of how the class changes over the interpolation.
#
# In the lecture, we used the attribution to act as a mask, to gradually go from the original image to the counterfactual image.
# This allowed us to classify all of the intermediate images, and learn how the class changed over the interpolation.
# Here we have a much simpler task so we have some advantages:
Expand Down Expand Up @@ -1053,17 +1063,6 @@ def visualize_color_attribution_and_counterfactual(
#
# %% [markdown]
# # Part 5: Exploring the Style Space, finding the answer
# By now you will have hopefully noticed that it isn't the exact color of the image that determines its class, but that two images with a very similar color can be of different classes!
#
# Here is an example of two images that are very similar in color, but are of different classes.
# ![same_color_diff_class](assets/same_color_diff_class.png)
# While both of the images are yellow, the attribution tells us (if you squint!) that one of the yellows has slightly more blue in it!
#
# Conversely, here is an example of two images with very different colors, but that are of the same class:
# ![same_class_diff_color](assets/same_class_diff_color.png)
# Here the attribution is empty! Using the discriminative attribution we can see that the significant color change doesn't matter at all!
#
#
# So color is important... but not always? What's going on!?
# There is a final piece of information that we can use to solve the puzzle: the style space.
# %% [markdown]
Expand Down

0 comments on commit 2b3882c

Please sign in to comment.