본문 바로가기

Language&Framework&Etc/Pytorch7

Pytorch dataset(sampler) 코드를 보다가 pytorch에서 sampler를 사용하길래 간단히 아래와 같이 코드를 짜서 output을 확인해서 어떤식으로 동작하는지 찾아보았다. import random import numpy as np import torch from torch.utils.data import Dataset, RandomSampler, BatchSampler random_seed = 8138 torch.manual_seed(random_seed) torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False np.random.seed(random_seed) random.seed(random_seed) torch.cuda.manual_s.. 2022. 6. 21.
Pytorch Multi-GPU 정리 중 용어 [노드] (분산 처리에서는 GPU가 달려 있는 machine을 node라는 용어로 지칭한다고 함) ex, 컴퓨터가 한 대 이면 node 1 ex, 컴퓨터가 두 대 이면 node 2 [World SIze] Number of processes participating in the job 작업에 사용되는 프로세스들의 개수 즉, 분산 처리에서 사용할 총 gpu 개수 [RANK] Rank는 Data Distributed Parallel에서 가동되는 process ID Global Rank: 전체 node에 가동되는 process id Local Rank: 각 node별 process id [Local Rank] 노드 내 프로세스의 로컬 순위 Local Rank를 0으로 한다면 0번째 GPU를 우선순위로 작업.. 2021. 12. 19.
Pytorch 데이터 로딩 방법 ImageFolder 이미지들이 폴더별로 클래스 형태로 정의되어 있을 때 사용할 수 있다. 아래의 pytorch 튜토리얼을 따라하다보면 hymenoptera_data를 이용하여 학습과 테스트를 진행한다. Finetuning Torchvision Models — PyTorch Tutorials 1.2.0 documentation Note Click here to download the full example code Finetuning Torchvision Models Author: Nathan Inkawhich In this tutorial we will take a deeper look at how to finetune and feature extract the torchvision models, al.. 2021. 6. 7.
AUTOGRAD : 자동 미분 (Pytorch tutorial) autograd autograd 패키지 - Tensor의 모든 연산에 대해 자동 미분 제공 (define-by-run) - 코드를 어떻게 작성하여 실행하느냐에 따라 역전파가 정의 Tensor - torch.Tensor → requires_grad → true하면, 그 tensor에서 이뤄진 모든 연산들을 추적(track)하기 시작 - 계산 완료후 .backward()를 호출하여 모든 변화도(gradient 기울기)를 자동으로 계산 가능 - 이 tensor의 gradient는 .grad에 누적 - 기록 추적 중단 : .detach - 기록 추적 방지 코드 블럭 : with torch.no_grad(): → requires_grad=True가 설정되어 학습 가능한 매개변수를 갖는 모델을 평가할 때 유리 Fu.. 2021. 4. 30.