DEV Community

4rldur0
4rldur0

Posted on

댑덥딥 5주차 정리

'모두를 위한 딥러닝 시즌 2' 강의를 듣고 공부하는 스터디 입니다. https://deeplearningzerotoall.github.io/season2/lec_tensorflow.html


비대면 10 May, 2023

09-3 Dropout

-overfitting 방지

?학습을 진행하면서 각 레이어에 존재하는 노드를 사전에 설정한 비율에 따라 껐다 켰다를 반복함→켜져있는 노드의 가중치만을 사용해 output을 계산함.

dropout = torch.nn.Dropout(p=drop_prob)
model = torch.nn.Sequential(linear1, relu, dropout, ... )
Enter fullscreen mode Exit fullscreen mode

*test할 때는 dropout 사용하지 않음

model.eval()      #dropout = False
Enter fullscreen mode Exit fullscreen mode

09-04 Batch Normalization

Gradient Vanishing/Exploding

Gradient Vanishing? 그래디언트가 작아지면서 소멸하는 현상

Gradient Exploding? vanishing문제와 반대. 미분을 계산할 때 값이 너무 크거나 nand값이 나올 때

→ change activation function, careful initialization, small learning rate(간접적 방식)

Batch Normalization

Internal Covariate Shift

Covariate Shift? test set와 train set의 분포에 차이가 있기에 발생하는 문제가 있다. 한 레이어의 입력과 출력의 분포에 차이가 있다.

-레이어마다 covariate shift가 있기 때문에 레이어가 깊어질수록 더 큰 변화가 발생

Batch Normalization? mini-batch마다 normalization을 하는 것

Image description

training: x→(m(=sample mean), sigma(=sample variance))normalize→x_hat, backpropagation→(gama,beta)scale and shift

한 train set 끝나면 sample mean/variance을 learning mean/variace로 고정→ gama*x_hat+beta 를 적용하여 batch normalize된 input을 활용

⇒batch data 구성이 달라져도 같은 output을 얻을 수 있음

[CNN]

10-1 Convolution

?이미지 위에서 stride 값 만큼 filter(kernel)을 이동시키면서 겹쳐지는 부분의 각 원소의 값을 곱해서 모두 더한 값을 출력으로 하는 연산

Image description

stride? filter를 한 번에 얼마나 이동할 것인가

padding: zero padding

Image description

Pytorch nn.Conv2d

torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0,
                            dilation=1, groups=1,bais=True)
Enter fullscreen mode Exit fullscreen mode

input type: torch.Tensor, shape:(batch_size, channel, height, weight)

ouput size = (input size-kernel size+(2*padding))/stride+1

-stride로 나눌 때 소수점 나오면 버리고 1 더하기

Image description

Neuron과 Convolution

convolution의 filter값이 perceptron의 weight값으로 들어감.

filter가 지나가는 input의 부분부분이 train data set

convolution filter도 bias를 가질 수 있음

Pooling

-이미지 사이즈를 줄이기 위해, fully connected 연산을 대체하기 위해

max pooling: 정해진 사이즈 안에서 가장 큰

average pooling: 정해진 사이즈 안에서 평균

torch.nn.MaxPool2d(kernel_size, stride=None, padding=0,
                            dilation=1, return_indices=False, ceil_mode=False)
Enter fullscreen mode Exit fullscreen mode

input → filter → conv → pool → output


대면 8 April, 2023

dropout, batch normalization

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay