본문 바로가기
머신러닝/기초 공부

[딥러닝] 기초 및 꿀팁 1

by 와플킴 2022. 9. 13.
728x90

 

Lecture 1

 

ML: 사람이 직접 feature 생성

DL: feature도 모델이 생성 (end-to-end, input을 넣으면 무조건 ouput이 나오는)

 

numpy: CPU 내에서만 수행

pytorch: GPU에서도 수행

 

torch.ones(3, 2)

torch.zeros(3, 2)

torch.manual_seed => seed 고정, 동일한 실험환경 구성할 때

torch.rand => 0부터 1사이

torch.randn => -1부터 1사이

 

y.add_(x) => y = y + x

in-place가 true 이면 input 값도 변함

 

numpy로 변환할 때는 CPU 내부에 있어야 함

a = a.cuda()

a = a.cpu()

 

device = torch.device("cuda:0")

a.to(device) // .cuda() => 첫 번쨰 GPU에 할당

 

requires_grad = True => 미분 가능, network 내 모든 parameters는 미분 가능해야 한다

미분 가능한 값을 이용한 모든 연산 결과는 미분 가능한 값으로 된다

 

backward() = dx/dt

print(x.grad)

연산 시작점의 변수, leaf node의 gradient만 측정이 된다

 

 

Lecture 2

 

MSE = (x * w - y)^2 의 평균

 

 

Lecture 3

 

gradient = dloss/dw

w = w - a(dloss/dw), (a = learning rate)

** imagenet, cifar (epoch을 많이 가질 수록 lr을 줄여야 함)

 

 

728x90

댓글