From dc5c63d3e5fcc98d7d0d407b207cbcc6935c027e Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sat, 4 Oct 2025 13:32:15 +0900 Subject: [PATCH 1/9] =?UTF-8?q?Captum=20Recipe=20=EB=B2=88=EC=97=AD=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0:=20attribution=20=EC=9A=A9=EC=96=B4=20?= =?UTF-8?q?=EC=9D=BC=EA=B4=80=EC=84=B1,=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=97=AD=EC=8A=AC=EB=9E=98=EC=8B=9C=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes/recipes/Captum_Recipe.py | 172 +++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 recipes/recipes/Captum_Recipe.py diff --git a/recipes/recipes/Captum_Recipe.py b/recipes/recipes/Captum_Recipe.py new file mode 100644 index 000000000..318a7024d --- /dev/null +++ b/recipes/recipes/Captum_Recipe.py @@ -0,0 +1,172 @@ +""" +Captum을 사용하여 모델 해석하기 +=================================== + +**번역**: `정재민 `_ +""" + + +###################################################################### +# Captum을 사용하면 데이터 특징(features)이 모델의 예측 또는 뉴런 활성화에 +# 미치는 영향을 이해하고, 모델의 동작 방식을 알 수 있습니다. +# +# 그리고 \ ``Integrated Gradients``\ 와 \ ``Guided GradCam``\ 과 같은 +# 최첨단의 feature attribution 알고리즘을 적용할 수 있습니다. +# +# 이 레시피에서는 Captum을 사용하여 다음을 수행하는 방법을 배웁니다: +# +# - 이미지 분류기(classifier)의 예측을 해당 이미지의 특징(features)에 표시하기 +# - 속성(attribution) 결과를 시각화 하기 + +###################################################################### +# 시작하기 전에 +# ---------------- +# + + +###################################################################### +# Captum이 Python 환경에 설치되어 있는지 확인해야 합니다. +# Captum은 Github에서 ``pip`` 패키지 또는 ``conda`` 패키지로 제공됩니다. +# 자세한 지침은 https://captum.ai/ 의 설치 안내서를 참조하면 됩니다. + +###################################################################### +# 모델의 경우, PyTorch에 내장 된 이미지 분류기(classifier)를 사용합니다. +# Captum은 샘플 이미지의 어떤 부분이 모델에 의해 만들어진 +# 특정한 예측에 도움을 주는지 보여줍니다. + +import torchvision +from torchvision import models, transforms +from PIL import Image +import requests +from io import BytesIO + +model = torchvision.models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1).eval() + +response = requests.get("https://image.freepik.com/free-photo/two-beautiful-puppies-cat-dog_58409-6024.jpg") +img = Image.open(BytesIO(response.content)) + +center_crop = transforms.Compose([ + transforms.Resize(256), + transforms.CenterCrop(224), +]) + +normalize = transforms.Compose([ + transforms.ToTensor(), # 이미지를 0에서 1사이의 값을 가진 Tensor로 변환 + transforms.Normalize( # 0을 중심으로 하는 imagenet 픽셀의 RGB 분포를 따르는 정규화 + mean=[0.485, 0.456, 0.406], + std=[0.229, 0.224, 0.225] + ) +]) +input_img = normalize(center_crop(img)).unsqueeze(0) + + +###################################################################### +# 속성(attribution) 계산하기 +# ------------------------------- + + +###################################################################### +# 모델의 top-3 예측 중에는 개와 고양이에 해당하는 클래스 208과 283이 있습니다. +# +# Captum의 \ ``Occlusion``\ 알고리즘을 사용하여 각 예측을 입력의 해당 부분에 표시합니다. + +from captum.attr import Occlusion + +occlusion = Occlusion(model) + +strides = (3, 9, 9) # 작을수록 = 세부적인 속성이지만 느림 +target=208, # ImageNet에서 Labrador의 인덱스 +sliding_window_shapes=(3,45, 45) # 객체의 모양을 변화시키기에 충분한 크기를 선택 +baselines = 0 # 이미지를 가릴 값, 0은 회색 + +attribution_dog = occlusion.attribute(input_img, + strides = strides, + target=target, + sliding_window_shapes=sliding_window_shapes, + baselines=baselines) + + +target=283, # ImageNet에서 Persian cat의 인덱스 +attribution_cat = occlusion.attribute(input_img, + strides = strides, + target=target, + sliding_window_shapes=sliding_window_shapes, + baselines=0) + + +###################################################################### +# Captum은 ``Occlusion`` 외에도 \ ``Integrated Gradients``\ , \ ``Deconvolution``\ , +# \ ``GuidedBackprop``\ , \ ``Guided GradCam``\ , \ ``DeepLift``\ , +# 그리고 \ ``GradientShap``\과 같은 많은 알고리즘을 제공합니다. +# 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 \ ``forward_func``\ 으로 기대하며 +# 속성(attribution) 결과를 통합해서 반환하는 ``attribute(...)`` 메소드를 가지는 +# ``Attribution`` 의 서브클래스 입니다. +# +# 이미지인 경우 속성(attribution) 결과를 시각화 해보겠습니다. +# + +###################################################################### +# 결과 시각화하기 +# ----------------------- +# + +###################################################################### +# Captum의 \ ``visualization``\ 유틸리티는 그림과 텍스트 입력 모두에 대한 +# 속성(attribution) 결과를 시각화 할 수 있는 즉시 사용가능한 방법을 제공합니다. +# + +import numpy as np +from captum.attr import visualization as viz + +# 계산 속성 Tensor를 이미지 같은 numpy 배열로 변환합니다. +attribution_dog = np.transpose(attribution_dog.squeeze().cpu().detach().numpy(), (1,2,0)) + +vis_types = ["heat_map", "original_image"] +vis_signs = ["all", "all"] # "positive", "negative", 또는 모두 표시하는 "all" +# positive 속성은 해당 영역의 존재가 예측 점수를 증가시킨다는 것을 의미합니다. +# negative 속성은 해당 영역의 존재가 예측 점수를 낮추는 오답 영역을 의미합니다. + +_ = viz.visualize_image_attr_multiple(attribution_dog, + np.array(center_crop(img)), + vis_types, + vis_signs, + ["attribution for dog", "image"], + show_colorbar = True + ) + + +attribution_cat = np.transpose(attribution_cat.squeeze().cpu().detach().numpy(), (1,2,0)) + +_ = viz.visualize_image_attr_multiple(attribution_cat, + np.array(center_crop(img)), + ["heat_map", "original_image"], + ["all", "all"], # positive/negative 속성 또는 all + ["attribution for cat", "image"], + show_colorbar = True + ) + + +###################################################################### +# 만약 데이터가 텍스트인 경우 ``visualization.visualize_text()`` 는 +# 입력 텍스트 위에 속성(attribution)을 탐색할 수 있는 전용 뷰(view)를 제공합니다. +# http://captum.ai/tutorials/IMDB_TorchText_Interpret 에서 자세한 내용을 확인하세요. +# + +###################################################################### +# 마지막 노트 +# --------------- +# + + +###################################################################### +# Captum은 이미지, 텍스트 등을 포함하여 다양한 방식으로 PyTorch에서 대부분의 모델 타입을 처리할 수 있습니다. +# Captum을 사용하면 다음을 수행할 수 있습니다. +# \* 위에서 설명한 것처럼 특정한 출력을 모델 입력에 표시하기 +# \* 특정한 출력을 은닉층의 뉴런에 표시하기 (Captum API reference를 보세요). +# \* 모델 입력에 대한 은닉층 뉴런의 반응을 표시하기 (Captum API reference를 보세요). +# +# 지원되는 메소드의 전체 API와 튜토리얼의 목록은 http://captum.ai 를 참조하세요. +# +# Gilbert Tanner의 또 다른 유용한 게시물 : +# https://gilberttanner.com/blog/interpreting-pytorch-models-with-captum +# From 426227ac66b21d0adb48f8f14d0722f88b8dc3e0 Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sat, 4 Oct 2025 13:51:35 +0900 Subject: [PATCH 2/9] =?UTF-8?q?recipes=5Fsource/recipes/Captum=5FRecipe.py?= =?UTF-8?q?=20=EC=98=A4=ED=83=88=EC=9E=90=20=EC=88=98=EC=A0=95:=20attribut?= =?UTF-8?q?ion=20=ED=91=9C=EA=B8=B0=20=ED=86=B5=EC=9D=BC=20=EB=B0=8F=20?= =?UTF-8?q?=EC=97=AD=EC=8A=AC=EB=9E=98=EC=8B=9C=20=EC=A0=9C=EA=B1=B0=20(fi?= =?UTF-8?q?xes=20#976)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes_source/recipes/Captum_Recipe.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/recipes_source/recipes/Captum_Recipe.py b/recipes_source/recipes/Captum_Recipe.py index 318a7024d..8006affdd 100644 --- a/recipes_source/recipes/Captum_Recipe.py +++ b/recipes_source/recipes/Captum_Recipe.py @@ -10,7 +10,7 @@ # Captum을 사용하면 데이터 특징(features)이 모델의 예측 또는 뉴런 활성화에 # 미치는 영향을 이해하고, 모델의 동작 방식을 알 수 있습니다. # -# 그리고 \ ``Integrated Gradients``\ 와 \ ``Guided GradCam``\ 과 같은 +# 그리고 ``Integrated Gradients`` 와 ``Guided GradCam`` 과 같은 # 최첨단의 feature attribution 알고리즘을 적용할 수 있습니다. # # 이 레시피에서는 Captum을 사용하여 다음을 수행하는 방법을 배웁니다: @@ -61,14 +61,14 @@ ###################################################################### -# 속성(attribution) 계산하기 +# 속성 계산하기 # ------------------------------- ###################################################################### # 모델의 top-3 예측 중에는 개와 고양이에 해당하는 클래스 208과 283이 있습니다. # -# Captum의 \ ``Occlusion``\ 알고리즘을 사용하여 각 예측을 입력의 해당 부분에 표시합니다. +# Captum의 ``Occlusion`` 알고리즘을 사용하여 각 예측을 입력의 해당 부분에 표시합니다. from captum.attr import Occlusion @@ -95,14 +95,14 @@ ###################################################################### -# Captum은 ``Occlusion`` 외에도 \ ``Integrated Gradients``\ , \ ``Deconvolution``\ , -# \ ``GuidedBackprop``\ , \ ``Guided GradCam``\ , \ ``DeepLift``\ , -# 그리고 \ ``GradientShap``\과 같은 많은 알고리즘을 제공합니다. -# 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 \ ``forward_func``\ 으로 기대하며 -# 속성(attribution) 결과를 통합해서 반환하는 ``attribute(...)`` 메소드를 가지는 +# Captum은 ``Occlusion`` 외에도 ``Integrated Gradients`` , ``Deconvolution`` , +# ``GuidedBackprop`` , ``Guided GradCam`` , ``DeepLift`` , +# 그리고 ``GradientShap``과 같은 많은 알고리즘을 제공합니다. +# 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 ``forward_func`` 으로 기대하며 +# 속성 결과를 통합해서 반환하는 ``attribute(...)`` 메소드를 가지는 # ``Attribution`` 의 서브클래스 입니다. # -# 이미지인 경우 속성(attribution) 결과를 시각화 해보겠습니다. +# 이미지인 경우 속성 결과를 시각화 해보겠습니다. # ###################################################################### @@ -111,8 +111,8 @@ # ###################################################################### -# Captum의 \ ``visualization``\ 유틸리티는 그림과 텍스트 입력 모두에 대한 -# 속성(attribution) 결과를 시각화 할 수 있는 즉시 사용가능한 방법을 제공합니다. +# Captum의 ``visualization`` 유틸리티는 그림과 텍스트 입력 모두에 대한 +# 속성 결과를 시각화 할 수 있는 즉시 사용가능한 방법을 제공합니다. # import numpy as np @@ -148,14 +148,13 @@ ###################################################################### # 만약 데이터가 텍스트인 경우 ``visualization.visualize_text()`` 는 -# 입력 텍스트 위에 속성(attribution)을 탐색할 수 있는 전용 뷰(view)를 제공합니다. +# 입력 텍스트 위에 속성을 탐색할 수 있는 전용 뷰(view)를 제공합니다. # http://captum.ai/tutorials/IMDB_TorchText_Interpret 에서 자세한 내용을 확인하세요. # ###################################################################### # 마지막 노트 # --------------- -# ###################################################################### From f3e4f663f3ceda3ad1c916d5f33b53c9038513e7 Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sat, 4 Oct 2025 13:54:11 +0900 Subject: [PATCH 3/9] =?UTF-8?q?=EC=9E=98=EB=AA=BB=EB=90=9C=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20recipes/recipes/Captum=5FRecipe.py=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes/recipes/Captum_Recipe.py | 172 ------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 recipes/recipes/Captum_Recipe.py diff --git a/recipes/recipes/Captum_Recipe.py b/recipes/recipes/Captum_Recipe.py deleted file mode 100644 index 318a7024d..000000000 --- a/recipes/recipes/Captum_Recipe.py +++ /dev/null @@ -1,172 +0,0 @@ -""" -Captum을 사용하여 모델 해석하기 -=================================== - -**번역**: `정재민 `_ -""" - - -###################################################################### -# Captum을 사용하면 데이터 특징(features)이 모델의 예측 또는 뉴런 활성화에 -# 미치는 영향을 이해하고, 모델의 동작 방식을 알 수 있습니다. -# -# 그리고 \ ``Integrated Gradients``\ 와 \ ``Guided GradCam``\ 과 같은 -# 최첨단의 feature attribution 알고리즘을 적용할 수 있습니다. -# -# 이 레시피에서는 Captum을 사용하여 다음을 수행하는 방법을 배웁니다: -# -# - 이미지 분류기(classifier)의 예측을 해당 이미지의 특징(features)에 표시하기 -# - 속성(attribution) 결과를 시각화 하기 - -###################################################################### -# 시작하기 전에 -# ---------------- -# - - -###################################################################### -# Captum이 Python 환경에 설치되어 있는지 확인해야 합니다. -# Captum은 Github에서 ``pip`` 패키지 또는 ``conda`` 패키지로 제공됩니다. -# 자세한 지침은 https://captum.ai/ 의 설치 안내서를 참조하면 됩니다. - -###################################################################### -# 모델의 경우, PyTorch에 내장 된 이미지 분류기(classifier)를 사용합니다. -# Captum은 샘플 이미지의 어떤 부분이 모델에 의해 만들어진 -# 특정한 예측에 도움을 주는지 보여줍니다. - -import torchvision -from torchvision import models, transforms -from PIL import Image -import requests -from io import BytesIO - -model = torchvision.models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1).eval() - -response = requests.get("https://image.freepik.com/free-photo/two-beautiful-puppies-cat-dog_58409-6024.jpg") -img = Image.open(BytesIO(response.content)) - -center_crop = transforms.Compose([ - transforms.Resize(256), - transforms.CenterCrop(224), -]) - -normalize = transforms.Compose([ - transforms.ToTensor(), # 이미지를 0에서 1사이의 값을 가진 Tensor로 변환 - transforms.Normalize( # 0을 중심으로 하는 imagenet 픽셀의 RGB 분포를 따르는 정규화 - mean=[0.485, 0.456, 0.406], - std=[0.229, 0.224, 0.225] - ) -]) -input_img = normalize(center_crop(img)).unsqueeze(0) - - -###################################################################### -# 속성(attribution) 계산하기 -# ------------------------------- - - -###################################################################### -# 모델의 top-3 예측 중에는 개와 고양이에 해당하는 클래스 208과 283이 있습니다. -# -# Captum의 \ ``Occlusion``\ 알고리즘을 사용하여 각 예측을 입력의 해당 부분에 표시합니다. - -from captum.attr import Occlusion - -occlusion = Occlusion(model) - -strides = (3, 9, 9) # 작을수록 = 세부적인 속성이지만 느림 -target=208, # ImageNet에서 Labrador의 인덱스 -sliding_window_shapes=(3,45, 45) # 객체의 모양을 변화시키기에 충분한 크기를 선택 -baselines = 0 # 이미지를 가릴 값, 0은 회색 - -attribution_dog = occlusion.attribute(input_img, - strides = strides, - target=target, - sliding_window_shapes=sliding_window_shapes, - baselines=baselines) - - -target=283, # ImageNet에서 Persian cat의 인덱스 -attribution_cat = occlusion.attribute(input_img, - strides = strides, - target=target, - sliding_window_shapes=sliding_window_shapes, - baselines=0) - - -###################################################################### -# Captum은 ``Occlusion`` 외에도 \ ``Integrated Gradients``\ , \ ``Deconvolution``\ , -# \ ``GuidedBackprop``\ , \ ``Guided GradCam``\ , \ ``DeepLift``\ , -# 그리고 \ ``GradientShap``\과 같은 많은 알고리즘을 제공합니다. -# 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 \ ``forward_func``\ 으로 기대하며 -# 속성(attribution) 결과를 통합해서 반환하는 ``attribute(...)`` 메소드를 가지는 -# ``Attribution`` 의 서브클래스 입니다. -# -# 이미지인 경우 속성(attribution) 결과를 시각화 해보겠습니다. -# - -###################################################################### -# 결과 시각화하기 -# ----------------------- -# - -###################################################################### -# Captum의 \ ``visualization``\ 유틸리티는 그림과 텍스트 입력 모두에 대한 -# 속성(attribution) 결과를 시각화 할 수 있는 즉시 사용가능한 방법을 제공합니다. -# - -import numpy as np -from captum.attr import visualization as viz - -# 계산 속성 Tensor를 이미지 같은 numpy 배열로 변환합니다. -attribution_dog = np.transpose(attribution_dog.squeeze().cpu().detach().numpy(), (1,2,0)) - -vis_types = ["heat_map", "original_image"] -vis_signs = ["all", "all"] # "positive", "negative", 또는 모두 표시하는 "all" -# positive 속성은 해당 영역의 존재가 예측 점수를 증가시킨다는 것을 의미합니다. -# negative 속성은 해당 영역의 존재가 예측 점수를 낮추는 오답 영역을 의미합니다. - -_ = viz.visualize_image_attr_multiple(attribution_dog, - np.array(center_crop(img)), - vis_types, - vis_signs, - ["attribution for dog", "image"], - show_colorbar = True - ) - - -attribution_cat = np.transpose(attribution_cat.squeeze().cpu().detach().numpy(), (1,2,0)) - -_ = viz.visualize_image_attr_multiple(attribution_cat, - np.array(center_crop(img)), - ["heat_map", "original_image"], - ["all", "all"], # positive/negative 속성 또는 all - ["attribution for cat", "image"], - show_colorbar = True - ) - - -###################################################################### -# 만약 데이터가 텍스트인 경우 ``visualization.visualize_text()`` 는 -# 입력 텍스트 위에 속성(attribution)을 탐색할 수 있는 전용 뷰(view)를 제공합니다. -# http://captum.ai/tutorials/IMDB_TorchText_Interpret 에서 자세한 내용을 확인하세요. -# - -###################################################################### -# 마지막 노트 -# --------------- -# - - -###################################################################### -# Captum은 이미지, 텍스트 등을 포함하여 다양한 방식으로 PyTorch에서 대부분의 모델 타입을 처리할 수 있습니다. -# Captum을 사용하면 다음을 수행할 수 있습니다. -# \* 위에서 설명한 것처럼 특정한 출력을 모델 입력에 표시하기 -# \* 특정한 출력을 은닉층의 뉴런에 표시하기 (Captum API reference를 보세요). -# \* 모델 입력에 대한 은닉층 뉴런의 반응을 표시하기 (Captum API reference를 보세요). -# -# 지원되는 메소드의 전체 API와 튜토리얼의 목록은 http://captum.ai 를 참조하세요. -# -# Gilbert Tanner의 또 다른 유용한 게시물 : -# https://gilberttanner.com/blog/interpreting-pytorch-models-with-captum -# From e6ae568cac50ced3d4698cef982d6e295a8c17ab Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sun, 12 Oct 2025 21:21:09 +0900 Subject: [PATCH 4/9] =?UTF-8?q?=EC=88=98=EC=A0=95:=20=EC=86=8D=EC=84=B1=20?= =?UTF-8?q?=EB=B3=91=EA=B8=B0=20=EA=B7=9C=EC=B9=99=20=EB=B0=98=EC=98=81=20?= =?UTF-8?q?=EB=B0=8F=20=ED=91=9C=ED=98=84=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes_source/recipes/Captum_Recipe.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/recipes_source/recipes/Captum_Recipe.py b/recipes_source/recipes/Captum_Recipe.py index 8006affdd..b3b023e0e 100644 --- a/recipes_source/recipes/Captum_Recipe.py +++ b/recipes_source/recipes/Captum_Recipe.py @@ -95,10 +95,17 @@ ###################################################################### +<<<<<<< Updated upstream # Captum은 ``Occlusion`` 외에도 ``Integrated Gradients`` , ``Deconvolution`` , # ``GuidedBackprop`` , ``Guided GradCam`` , ``DeepLift`` , # 그리고 ``GradientShap``과 같은 많은 알고리즘을 제공합니다. # 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 ``forward_func`` 으로 기대하며 +======= +# Captum은 ``Occlusion`` 외에도 \ ``Integrated Gradients``\ , \ ``Deconvolution``\ , +# \ ``GuidedBackprop``\ , \ ``Guided GradCam``\ , \ ``DeepLift``\ , +# 그리고 \ ``GradientShap``\과 같은 많은 알고리즘을 제공합니다. +# 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 \ ``forward_func``\ 으로 기대하며 +>>>>>>> Stashed changes # 속성 결과를 통합해서 반환하는 ``attribute(...)`` 메소드를 가지는 # ``Attribution`` 의 서브클래스 입니다. # @@ -111,7 +118,11 @@ # ###################################################################### +<<<<<<< Updated upstream # Captum의 ``visualization`` 유틸리티는 그림과 텍스트 입력 모두에 대한 +======= +# Captum의 \ ``visualization``\ 유틸리티는 그림과 텍스트 입력 모두에 대한 +>>>>>>> Stashed changes # 속성 결과를 시각화 할 수 있는 즉시 사용가능한 방법을 제공합니다. # From ba77664bc552bb047c8d348a5b666911353a9f71 Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sun, 12 Oct 2025 21:29:45 +0900 Subject: [PATCH 5/9] =?UTF-8?q?Resolve:=20=EC=B6=A9=EB=8F=8C=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9D=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=B5=9C=EC=A2=85?= =?UTF-8?q?=EB=B3=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes_source/recipes/Captum_Recipe.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/recipes_source/recipes/Captum_Recipe.py b/recipes_source/recipes/Captum_Recipe.py index b3b023e0e..cd0a57ee4 100644 --- a/recipes_source/recipes/Captum_Recipe.py +++ b/recipes_source/recipes/Captum_Recipe.py @@ -10,14 +10,14 @@ # Captum을 사용하면 데이터 특징(features)이 모델의 예측 또는 뉴런 활성화에 # 미치는 영향을 이해하고, 모델의 동작 방식을 알 수 있습니다. # -# 그리고 ``Integrated Gradients`` 와 ``Guided GradCam`` 과 같은 +# 그리고 \ ``Integrated Gradients``\ 와 \ ``Guided GradCam``\ 과 같은 # 최첨단의 feature attribution 알고리즘을 적용할 수 있습니다. # # 이 레시피에서는 Captum을 사용하여 다음을 수행하는 방법을 배웁니다: # # - 이미지 분류기(classifier)의 예측을 해당 이미지의 특징(features)에 표시하기 -# - 속성(attribution) 결과를 시각화 하기 - +# - 속성(attribution) 결과를 시각화하기 +# ###################################################################### # 시작하기 전에 # ---------------- @@ -30,7 +30,7 @@ # 자세한 지침은 https://captum.ai/ 의 설치 안내서를 참조하면 됩니다. ###################################################################### -# 모델의 경우, PyTorch에 내장 된 이미지 분류기(classifier)를 사용합니다. +# 모델의 경우, PyTorch에 내장된 이미지 분류기(classifier)를 사용합니다. # Captum은 샘플 이미지의 어떤 부분이 모델에 의해 만들어진 # 특정한 예측에 도움을 주는지 보여줍니다. @@ -63,12 +63,13 @@ ###################################################################### # 속성 계산하기 # ------------------------------- +# ###################################################################### # 모델의 top-3 예측 중에는 개와 고양이에 해당하는 클래스 208과 283이 있습니다. # -# Captum의 ``Occlusion`` 알고리즘을 사용하여 각 예측을 입력의 해당 부분에 표시합니다. +# Captum의 \ ``Occlusion``\ 알고리즘을 사용하여 각 예측을 입력의 해당 부분에 표시합니다. from captum.attr import Occlusion @@ -95,17 +96,10 @@ ###################################################################### -<<<<<<< Updated upstream -# Captum은 ``Occlusion`` 외에도 ``Integrated Gradients`` , ``Deconvolution`` , -# ``GuidedBackprop`` , ``Guided GradCam`` , ``DeepLift`` , -# 그리고 ``GradientShap``과 같은 많은 알고리즘을 제공합니다. -# 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 ``forward_func`` 으로 기대하며 -======= # Captum은 ``Occlusion`` 외에도 \ ``Integrated Gradients``\ , \ ``Deconvolution``\ , # \ ``GuidedBackprop``\ , \ ``Guided GradCam``\ , \ ``DeepLift``\ , # 그리고 \ ``GradientShap``\과 같은 많은 알고리즘을 제공합니다. # 이러한 모든 알고리즘은 초기화할 때 모델을 호출 가능한 \ ``forward_func``\ 으로 기대하며 ->>>>>>> Stashed changes # 속성 결과를 통합해서 반환하는 ``attribute(...)`` 메소드를 가지는 # ``Attribution`` 의 서브클래스 입니다. # @@ -118,11 +112,7 @@ # ###################################################################### -<<<<<<< Updated upstream -# Captum의 ``visualization`` 유틸리티는 그림과 텍스트 입력 모두에 대한 -======= # Captum의 \ ``visualization``\ 유틸리티는 그림과 텍스트 입력 모두에 대한 ->>>>>>> Stashed changes # 속성 결과를 시각화 할 수 있는 즉시 사용가능한 방법을 제공합니다. # @@ -166,13 +156,14 @@ ###################################################################### # 마지막 노트 # --------------- +# ###################################################################### # Captum은 이미지, 텍스트 등을 포함하여 다양한 방식으로 PyTorch에서 대부분의 모델 타입을 처리할 수 있습니다. # Captum을 사용하면 다음을 수행할 수 있습니다. # \* 위에서 설명한 것처럼 특정한 출력을 모델 입력에 표시하기 -# \* 특정한 출력을 은닉층의 뉴런에 표시하기 (Captum API reference를 보세요). +# \* 특정한 출outputs을 은닉층의 뉴런에 표시하기 (Captum API reference를 보세요). # \* 모델 입력에 대한 은닉층 뉴런의 반응을 표시하기 (Captum API reference를 보세요). # # 지원되는 메소드의 전체 API와 튜토리얼의 목록은 http://captum.ai 를 참조하세요. From 06ce79fd8174820252cdd2db36cc0fcb15f8d702 Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sun, 12 Oct 2025 21:31:19 +0900 Subject: [PATCH 6/9] =?UTF-8?q?Resolve:=20=EC=B6=A9=EB=8F=8C=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9D=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=B5=9C=EC=A2=85?= =?UTF-8?q?=EB=B3=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes_source/recipes/Captum_Recipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes_source/recipes/Captum_Recipe.py b/recipes_source/recipes/Captum_Recipe.py index cd0a57ee4..67bd17f4c 100644 --- a/recipes_source/recipes/Captum_Recipe.py +++ b/recipes_source/recipes/Captum_Recipe.py @@ -163,7 +163,7 @@ # Captum은 이미지, 텍스트 등을 포함하여 다양한 방식으로 PyTorch에서 대부분의 모델 타입을 처리할 수 있습니다. # Captum을 사용하면 다음을 수행할 수 있습니다. # \* 위에서 설명한 것처럼 특정한 출력을 모델 입력에 표시하기 -# \* 특정한 출outputs을 은닉층의 뉴런에 표시하기 (Captum API reference를 보세요). +# \* 특정한 출력을 은닉층의 뉴런에 표시하기 (Captum API reference를 보세요). # \* 모델 입력에 대한 은닉층 뉴런의 반응을 표시하기 (Captum API reference를 보세요). # # 지원되는 메소드의 전체 API와 튜토리얼의 목록은 http://captum.ai 를 참조하세요. From de7d04608dcf087df336f7ab7b68160c2d3fcb75 Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sun, 12 Oct 2025 21:37:18 +0900 Subject: [PATCH 7/9] =?UTF-8?q?Resolve:=20=EC=B6=A9=EB=8F=8C=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9D=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=B5=9C=EC=A2=85?= =?UTF-8?q?=EB=B3=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes_source/recipes/Captum_Recipe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes_source/recipes/Captum_Recipe.py b/recipes_source/recipes/Captum_Recipe.py index 67bd17f4c..818617bb5 100644 --- a/recipes_source/recipes/Captum_Recipe.py +++ b/recipes_source/recipes/Captum_Recipe.py @@ -16,7 +16,7 @@ # 이 레시피에서는 Captum을 사용하여 다음을 수행하는 방법을 배웁니다: # # - 이미지 분류기(classifier)의 예측을 해당 이미지의 특징(features)에 표시하기 -# - 속성(attribution) 결과를 시각화하기 +# - 속성(attribution) 결과를 시각화 하기 # ###################################################################### # 시작하기 전에 @@ -30,7 +30,7 @@ # 자세한 지침은 https://captum.ai/ 의 설치 안내서를 참조하면 됩니다. ###################################################################### -# 모델의 경우, PyTorch에 내장된 이미지 분류기(classifier)를 사용합니다. +# 모델의 경우, PyTorch에 내장 된 이미지 분류기(classifier)를 사용합니다. # Captum은 샘플 이미지의 어떤 부분이 모델에 의해 만들어진 # 특정한 예측에 도움을 주는지 보여줍니다. From b344a96898d098b1d5597f853743493f73855606 Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sun, 12 Oct 2025 21:38:30 +0900 Subject: [PATCH 8/9] =?UTF-8?q?Resolve:=20=EC=B6=A9=EB=8F=8C=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9D=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=B5=9C=EC=A2=85?= =?UTF-8?q?=EB=B3=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes_source/recipes/Captum_Recipe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes_source/recipes/Captum_Recipe.py b/recipes_source/recipes/Captum_Recipe.py index 818617bb5..9adfbb33a 100644 --- a/recipes_source/recipes/Captum_Recipe.py +++ b/recipes_source/recipes/Captum_Recipe.py @@ -17,7 +17,7 @@ # # - 이미지 분류기(classifier)의 예측을 해당 이미지의 특징(features)에 표시하기 # - 속성(attribution) 결과를 시각화 하기 -# + ###################################################################### # 시작하기 전에 # ---------------- @@ -63,7 +63,7 @@ ###################################################################### # 속성 계산하기 # ------------------------------- -# + ###################################################################### From 998d2c89839856b3bba91d8b2c2f112e39606a09 Mon Sep 17 00:00:00 2001 From: Brdy8294 Date: Sun, 12 Oct 2025 21:39:22 +0900 Subject: [PATCH 9/9] =?UTF-8?q?Resolve:=20=EC=B6=A9=EB=8F=8C=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9D=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=B5=9C=EC=A2=85?= =?UTF-8?q?=EB=B3=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recipes_source/recipes/Captum_Recipe.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes_source/recipes/Captum_Recipe.py b/recipes_source/recipes/Captum_Recipe.py index 9adfbb33a..9cf410dc6 100644 --- a/recipes_source/recipes/Captum_Recipe.py +++ b/recipes_source/recipes/Captum_Recipe.py @@ -65,7 +65,6 @@ # ------------------------------- - ###################################################################### # 모델의 top-3 예측 중에는 개와 고양이에 해당하는 클래스 208과 283이 있습니다. #