ML&DL 이야기
-
[PyTorchZerotoAll 내용정리] 05 Linear Regression in pytorch(pytorch Project 개발순서 익히기)ML&DL 이야기/Pytroch 2023. 8. 23. 15:20
Pytorch Project Rhythm pytroch 모델을 개발하고 학습하는 사이클을 크게 위의 3단계를 거친다. 위에 1에 우선시 되는 단계도 있어서(강의에서도 간단히 언급하고 넘어감) 이를 토대로 정리하고 각 코드가 어떻게 대치되는지 확인해보자. 0. Data 다루기 torch.autograd.Variable는 2021.01.12 기준 1.7 version에서는 더 이상 사용되지 않습니다. 현재는 모든 tensor가 자동적으로 Variable의 성질을 가지기 때문에 굳이 사용할 필요가 없으나(즉, autograd 설정이 가능합니다) 과거 버전의 코드를 수행함에 있어 Variable을 사용하는 경우가 있습니다 import torch 이후에 여러 패키지를 import하고, 이후 학습에 필요한 데이터를..
-
[PyTorchZerotoAll 내용정리] 04 Back propagationML&DL 이야기/Pytroch 2023. 8. 16. 10:10
Why Backpropagation? Neural Network 학습의 최종적인 목표는 Cost를 최소화시키는 Neural Network 내의 모든 Unit의 가중치 W 를 찾는 것이다. 우리가 익히 아는 Gradient Descent Algorithm을 이용해 이를 최적화한다고 하다. 이를 위해서는 간단히 인공지능의 역사를 알아야하는데, 간단하게 말하면, 이전에 우리가 흔히 아는 퍼셉트론(NN의 한 unit)으로 문제를 해결하려고 했지만, 1969년, MIT의 마빈 민스키와 시모어 패퍼트는 저서 에서, 퍼셉트론이 선형 분리가 불가능한 데이터들을 분류할 수 없음을 증명하면서 인공지능의 겨울이 찾아왔다. 해당 저서에서 다층 퍼셉트론으로는 XOR 연산을 할 수 있다고 밝혔지만, ‘지구 상의 그 누구도 이를 ..
-
[PyTorchZerotoAll 내용정리] 03 Gradeint DescentML&DL 이야기/Pytroch 2023. 8. 15. 15:52
우리는 가중치 값에 따라서 에러를 가장 줄이는 w를 찾아보고 싶다. 이를 알기 위해서는 물론 미분을 해서 최적값을 찾아도 되지만, 우리가 앞으로 다룰, 또 대다수의 함수들은 여러가지 변수로 구성되어있기에 이런 방법으로는 최적값을 찾는 것이 불가하다. 그럼으로 적용가능한 알고리즘이 필요한데, 그 이름도 유명한 gradient desecent 알고리즘이다. 이 알고리즘은 산을 타면서 한 step마다 가장 가파른 방향으로 이동한다라고 생각하면 된다. 왜 Gradient 방향이 가장 가파른가? gradient와 방향도함수의 정의를 각각 먼저 살펴보자. Gradient란? f(x,y,z)의 기울기 벡터 또는 gradeint는 다음과 같이 정의된다. $$ \nabla f = \frac{\partial f}{\par..
-
[PyTorchZerotoAll 내용정리] 02 Linear ModelML&DL 이야기/Pytroch 2023. 8. 15. 14:36
Supervised Learning supervised learning이란 지도학습으로 답이 이미 존재하는 labled dataset으로 모델을 훈련시키는 경우를 의미한다. 지도 학습 알고리즘의 일반 유형 지도 학습 알고리즘에는 크게 두 가지 유형이 있다. 1. 분류 기법(Classification techniques) 분류 기법은 입력 데이터를 특정 클래스 또는 그룹의 구성원으로 식별하기 위해 알고리즘에 이산 값을 예측하도록 요청한다. 다음과 같은 알고리즘의 예시가 있다 1.1) 로지스틱 회귀 1.2) 선형 분류 1.3) KNN 알고리즘 1..4) 트리 1.5) SVM 2. 선형 회귀 (Linear regression) 선형 회귀분석은 연속 데이터를 사용한다. 대수학 문제처럼 x의 값을 알고 있다면, ..
-
[PyTorchZerotoAll 내용정리] 01 OverviewML&DL 이야기/Pytroch 2023. 8. 10. 15:23
출처: 본 내용은 아래의 Sung Kim(HKUST)님의 PyTorchZerotoAll의 내용을 기반으로 Pytorch 공식문서의 내용과 함께 정리한 것입니다. 영상: https://youtu.be/SKq-pmkekTk Code: https://github.com/hunkim/PyTorchZero... Slides: http://bit.ly/PyTorchZeroAll What is ML? ML에 관해 알아보기 전에 Human Intelligence에 관해 알아보자. 사람들은 결정을 내릴 때, information(정보)에서 output을 생각해낸다. 예를 들어 점심에 무엇을 먹을지 결정할때(내가 항상 고민하는 거다), 우리는 우리가 무엇을 좋아하는지, 싫어하는지, 오늘 점심 메뉴는 뭔지 등 여러 정보를 ..
-
Likelihood(우도, 가능도)와 MLE(Maximum Likelihood Estimaton)ML&DL 이야기/ML 2023. 7. 26. 17:51
Likelihood(우도, 가능도) 데이터가 만일 위의 그림처럼 1,4,5,6,9가 나왔을 때 분포는 주황색으로 추정하는 것이 옳을까?, 아니면 파란색으로 추정하는 것이 좋을까? 우도란 이런 정도를 나타내는 것으로, 정리하면 "데이터가 해당 분포로 부터 나왔을 가능성(liklihood)" 확률은 모수가 정해진 상태에서 특정 data가 관측될 확률이고(말이 이상하지만..!), Likelihood는 Data가 관측된 상태에서 특정 확률분포에 대한 "모수"를 추정할 수 있는 믿음의 정도..?이다. 즉, 특정 모수 하의 x가 나올 확률은 x에 관한 모수의 가능도와 같다! 우리가 가지고 있는 데이터는 MLE(최대 우도 법) 최대우도법은 모수를 추정하는 방법으로, 데이터로부터 모수의 값을 추정할 때 사용하는 방법니..
-
[ML] L1함수와 L2함수 입장에서의 Loss FuntionML&DL 이야기/ML 2023. 7. 25. 17:48
파이토치는 다양한 손실함수들을 제공하는데, 이는 흔히 말하는 cost function, loss function, objective function 등의 이름으로 사용된다. 이런 손실함수들은 모델의 predict 값과 target 값의 차이를 측정하여 모델의 학습을 도와준다. Loss function의 2가지 가정 DNN에서 Loss Function을 사용할 때 아래의 2가지 가정에 적합해야 한다. 1) Train data에서의 Loss 총합은 개별 데이터 Loss의 합과 같아야 한다. $$ L(\theta_{k}, D) = \sum_{i}L(\theta_{k} ,D_{i}) $$ 2) DNN 출력 값으로 Loss를 계산한다. (중간 단계에서의 값으로는 계산하지 않음.) $$ \bigtriangledow..