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
5 changes: 2 additions & 3 deletions advanced_source/semi_structured_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ def measure_execution_time(model, batch_sizes, dataset):
return batch_size_to_time_sec



######################################################################
# 모델과 토크나이저를 로드한 후, 데이터셋을 설정하면서 시작하겠습니다.
#
Expand Down Expand Up @@ -491,7 +490,7 @@ def measure_execution_time(model, batch_sizes, dataset):


######################################################################
# 모델의 매개변수화는 첫 번째 단계는 모델의 가중치를 마스킹하기 위한 매개변수화를 삽입하는 것입니다.
# 모델의 모델의 가지치기를 위한 첫번째 단계는 모델의 가중치를 마스킹하기 위한 매개변수화를 삽입하는 것입니다.
# 이는 준비 단계에서 수행됩니다. 이렇게 하면 ``.weight``에 접근할 때마다 대신 ``mask * weight``를
# 얻게 됩니다.
#
Expand All @@ -503,7 +502,7 @@ def measure_execution_time(model, batch_sizes, dataset):

######################################################################
# 그 다음, 단일 가지치기 단계를 수행합니다. 모든 가지치기 도구(pruner)는 가지치기 도구의 구현
# 논리에 따라 마스크를 업데이트하는 ``update_mask()`` 메서드를 구현합니다. 이 단계 메서드는
# 논리에 따라 마스크를 업데이트하는 ``update_mask()`` 메소드를 구현합니다. 이 단계 메소드는
# 희소성 설정(sparse config)에서 지정된 가중치에 대해 이 ``update_mask`` 함수를 호출합니다.
#
# 또한 모델을 평가하여 미세 조정/재학습 없이 가지치기(zero-shot) 또는 가지치기의 정확도 저하를 보여줄 것입니다.
Expand Down
2 changes: 1 addition & 1 deletion beginner_source/introyt/tensorboardyt_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def forward(self, x):
# 검증 셋과 비교
running_vloss = 0.0

# 평가 모드에서는 일부 모델의 특정 작업을 생략할 수 있습니다 예시: 드롭아웃 레이어
# 평가 모드에서는 일부 모델의 특정 작업을 생략할 수 있습니다 예시: Drop-out 계층
net.train(False) # 평가 모드로 전환, 예시: 정규화(regularisation) 끄기
for j, vdata in enumerate(validation_loader, 0):
vinputs, vlabels = vdata
Expand Down
8 changes: 4 additions & 4 deletions intermediate_source/tiatoolbox_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ TIAToolbox를 사용하면 `조직
import torch
from torchvision import transforms

# 그래프 설정
# 그래프 도식화
mpl.rcParams["figure.dpi"] = 160 # for high resolution figure in notebook
mpl.rcParams["figure.facecolor"] = "white" # To make sure text is visible in dark mode

Expand Down Expand Up @@ -381,7 +381,7 @@ PatchPredictor 클래스는 PyTorch로 작성된 CNN 기반 분류기를 실행
~~~~~~~~~~~~~~~~~~~~

예측기(predictor) 객체를 생성한 후 ``patch`` 모드를 사용하여 ``predict`` 메소드를 호출합니다.
그런 다음, 분류 정확도와 오차 행렬(confusion matrix)을 계산합니다.
그런 다음, 분류 정확도와 혼동 행렬(confusion matrix)을 계산합니다.



Expand All @@ -395,7 +395,7 @@ PatchPredictor 클래스는 PyTorch로 작성된 CNN 기반 분류기를 실행
acc = accuracy_score(label_list, output["predictions"])
logger.info("Classification accuracy: %f", acc)

# 패치 분류 결과를 위한 오차 행렬(confusion_matrix) 생성 및 시각화
# 패치 분류 결과를 위한 혼동 행렬(confusion_matrix) 생성 및 시각화
conf = confusion_matrix(label_list, output["predictions"], normalize="true")
df_cm = pd.DataFrame(conf, index=class_names, columns=class_names)
df_cm
Expand Down Expand Up @@ -823,7 +823,7 @@ TIAToolbox는 PyTorch의 `nn.Module <https://pytorch.org/docs/stable/generated/t
"""
img_patches_device = batch_data.to('cuda') if on_gpu else batch_data
model.eval()
# 기울기를 계산하지 않음(훈련이 아님)
# 변화도를 계산하지 않음(훈련이 아님)
with torch.inference_mode():
output = model(img_patches_device)
return [output.cpu().numpy()]
Expand Down
6 changes: 3 additions & 3 deletions recipes_source/recipes/amp_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def make_model(in_size, out_size, num_layers):
# 변화도 확인/수정하기 (예: 클리핑)
# --------------------------
# ``scaler.scale(loss).backward()`` 로 생성된 모든 변화도는 조정됩니다.
# 만약 ``backward()`` 와 ``scaler.step(optimizer)`` 사이에서 파라미터의
# 만약 ``backward()`` 와 ``scaler.step(optimizer)`` 사이에서 매개변수의
# ``.grad`` 속성을 수정하거나 확인하고 싶다면, 먼저
# `scaler.unscale_(optimizer) <https://pytorch.org/docs/stable/amp.html#torch.cuda.amp.GradScaler.unscale_>`_
# 를 사용하여 변화도를 복원해야 합니다.
Expand All @@ -210,10 +210,10 @@ def make_model(in_size, out_size, num_layers):
loss = loss_fn(output, target)
scaler.scale(loss).backward()

# 옵티마이저에 할당된 파라미터의 변화도를 제자리에서 복원합니다.
# 옵티마이저에 할당된 매개변수의 변화도를 제자리에서 복원합니다.
scaler.unscale_(opt)

# 옵티마이저에 할당된 파라미터의 변화도가 이제 복원되었으므로, 평소와 같이 클리핑할 수 있습니다.
# 옵티마이저에 할당된 매개변수의 변화도가 이제 복원되었으므로, 평소와 같이 클리핑할 수 있습니다.
# 이때 클리핑에 사용하는 max_norm 값은 변화도 조정이 없을 때와 동일하게 사용할 수 있습니다.
torch.nn.utils.clip_grad_norm_(net.parameters(), max_norm=0.1)

Expand Down
18 changes: 9 additions & 9 deletions recipes_source/recipes/tuning_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def gelu(x):
# 효율을 개선할 수 있습니다.
#
# 체크포인트 저장할 대상은 신중하게 선택해야 합니다. 가장 좋은 방법은 재계산 비용이 적은 대규모
# 레이어의 출력을 저장하지 않는 것입니다. 예를 들어, 활성화 함수(예시: ``ReLU`` , ``Sigmoid``
# 계층의 출력을 저장하지 않는 것입니다. 예를 들어, 활성화 함수(예시: ``ReLU`` , ``Sigmoid``
# , ``Tanh`` ), up/down 샘플링, 작은 누적 깊이(accumulation depth)를 가진 행렬-벡터 연산
# 등이 체크포인트 저장 대상으로 적합합니다.
#
Expand Down Expand Up @@ -387,7 +387,7 @@ def gelu(x):
# 장치에서 생성합니다.
# ``torch.rand(size, device='cuda')``
#
# 이는 다음과 같이 ``device`` 인수를 받아 새로운 tensor를 생성하는 모든 함수에 적용됩니다:
# 이는 다음과 같이 ``device`` 인자를 받아 새로운 tensor를 생성하는 모든 함수에 적용됩니다:
# `torch.rand() <https://pytorch.org/docs/stable/generated/torch.rand.html#torch.rand>`_,
# `torch.zeros() <https://pytorch.org/docs/stable/generated/torch.zeros.html#torch.zeros>`_,
# `torch.full() <https://pytorch.org/docs/stable/generated/torch.full.html#torch.full>`_
Expand All @@ -408,8 +408,8 @@ def gelu(x):
#
# * `Deep Learning Performance Documentation
# <https://docs.nvidia.com/deeplearning/performance/index.html#optimizing-performance>`_
# 에서 자세한 정보와 레이어 유형에 따른 가이드라인을 참조하세요.
# * 레이어 크기가 고정되지 않고 다른 매개변수에서 유도되는 경우에도 명시적으로 패딩할 수 있습니다.
# 에서 자세한 정보와 계층 유형에 따른 가이드라인을 참조하세요.
# * 계층 크기가 고정되지 않고 다른 매개변수에서 유도되는 경우에도 명시적으로 패딩할 수 있습니다.
# (예시: NLP 모델의 어휘 크기 등).
#
# * AMP 활성화하기
Expand Down Expand Up @@ -478,13 +478,13 @@ def gelu(x):
# 따르고 필요한 변화도 all-reduce를 수행해야 합니다.

###############################################################################
# ``DistributedDataParallel(find_unused_parameters=True)`` 를 사용할 때 생성자와 실행 레이어 순서를 일치시키는 방법
# ``DistributedDataParallel(find_unused_parameters=True)`` 를 사용할 때 생성자와 실행 계층 순서를 일치시키는 방법
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# `torch.nn.parallel.DistributedDataParallel <https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html#torch.nn.parallel.DistributedDataParallel>`_
# 은 ``find_unused_parameters=True`` 와 함께 모델 생성자에서의 레이어와 파라미터 순서를
# 은 ``find_unused_parameters=True`` 와 함께 모델 생성자에서의 계층과 매개변수 순서를
# 사용하여 ``DistributedDataParallel`` 변화도 all-reduce를 위한 버킷을 만듭니다.
# ``DistributedDataParallel`` 은 all-reduce를 역전파와 겹치게 수행합니다. 특정 버킷에 대한
# all-reduce는 주어진 버킷의 모든 파라미터에 대한 변화도가 모두 준비되었을 때 비동기적으로 작동됩니다.
# all-reduce는 주어진 버킷의 모든 매개변수에 대한 변화도가 모두 준비되었을 때 비동기적으로 작동됩니다.
#
# 최대로 겹치게 하려면 모델 생성자에서의 순서가 실제 실행 중인 순서와 대략적으로 일치해야 합니다.
# 순서가 맞지 않으면 전체 버킷에 대한 all-reduce는 마지막으로 도착하는 변화도를 기다리게 되며,
Expand All @@ -493,8 +493,8 @@ def gelu(x):
#
# ``find_unused_parameters=False`` 가 (기본 설정)인 ``DistributedDataParallel`` 은
# 역전파 중에 발견된 연산 순서를 기반으로 자동으로 버킷을 형성합니다.
# ``find_unused_parameters=False`` 를 사용할 때는 최적의 성능을 달성하기 위해 레이어나
# 파라미터의 순서를 재조정할 필요가 없습니다.
# ``find_unused_parameters=False`` 를 사용할 때는 최적의 성능을 달성하기 위해 계층이나
# 매개변수의 순서를 재조정할 필요가 없습니다.

###############################################################################
# 분산 설정에서 작업 부하를 분산하는 방법
Expand Down