Machine Learning
-
Multiclass Classification | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 3. 24. 16:08
Coursera Machine Learning Specialization > Supervised Machine Learning: Advanced Learning Algorithms > Neural Network Intuition Multiclass Multiclass Classification은 분류 문제 중, 여러가지의 Class를 판별하는 문제이다. Logistic Regression을 이용해서 y가 0이거나 1인 확률을 계산하고, threash hold값을 이용해서(예: 0.5) 판별해내는 모델을 배웠었다. 하지만 그 가지수가 2개 이상이라면? 여러 포켓몬이 있다고 가정해보자. 그러면 그래프상으로 각 결과값마다 결정 경계(Decision Boundry)가 생기고, 그 경계선을 갖고 여러가지의 cla..
-
Activation Functions | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 3. 24. 13:57
Coursera Machine Learning Specialization > Supervised Machine Learning: Advanced Learning Algorithms > Neural Network Intuition Alternatives to the sigmoid activation 지금까지는 Activation 함수로 Sigmoid 함수를 써왔다. 티셔츠가 얼마나 팔릴지에대한 Demand Prediction을 계산할 때, price, shipping cost, marketing, material등의 값을 이용해서 여러가지 값을 측정한다고 생각해보자. 그 중, awareness(인지도) 값을 0이나 1인 binary가 아니라, 음수가 아닌 0과 1 사이 숫자로 표현해보자. 이전에는 sigm..
-
TensorFlow Training Details | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 2. 11. 14:54
Coursera Machine Learning Specialization > Supervised Machine Learning: Regression and Classification > Regression with multiple input variables 이전 시간에서 모델을 트레이닝 하는 코드를 써봤는데, 실제로 이 코드가 무엇을 하는지 살펴보자. Neural Network의 세부 사항을 살펴보기 전에, 이전에 Logistic Regression 모델을 어떻게 훈련했었는지 기억해보자. Logistic Regression 먼저 1단계로, Feature들인 x와, weight(w), bias(b)가 주어지면 출력값을 계산하는 방법을 지정해주는 단계였다. W와 X를 dot product한 값에 b를 더한..
-
TensorFlow Implementation | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 2. 11. 13:07
Coursera Machine Learning Specialization > Supervised Machine Learning: Advanced Learning Algorithms > Neural Network Intuition 이 Neural Network를 코드로 표현해보자. 먼저, tensorflow를 import하고, 각 레이어를 Dense를 이용해서 생성하고, Sequential을 이용해서 Neural Network를 생성할 수 있다. import tensorflow as tf from tensorflow.keras import Sequential from tensorflow.keras.layers import Dense 자, 이제 하나하나의 Layer를 만들고, 그것을 순차적으로 갖고있는 모델..
-
Matrix Multiplication Code | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 2. 10. 20:59
Coursera Machine Learning Specialization > Supervised Machine Learning: Advanced Learning Algorithms > Neural Network Intuition 이제 전에 직접 계산했던것을 NumPy를 이용해서 계산해보자. 먼저 A matrix를 아래와 같이 생성할 수 있다. A = np.array([1, -1, 0.1], [2, -2, 0.2]]) 이제 이 matrix를 transpose 한 matrix를 생성해보자. AT = np.array([[1, 2], [-1, -2], [0.1, 0.2]]) 매번 이렇게 직접 쓰지 않아도, 원래의 matrix가 있다면, transpose를 이렇게 할 수 있다. AT = A.T 그리고 W matr..
-
Matrix Multiplication Rules | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 2. 10. 18:40
Coursera Machine Learning Specialization > Supervised Machine Learning: Advanced Learning Algorithms > Neural Network Intuition 이번에는 Matrix를 곱할때 규칙들을 살펴보자. 아래와 같은 Matrix를 살펴보자. A를 Transpose 하게 되면 3x2 matrix가 된다. 이것을 2 x 4 matrix인 W와 곱하게 되면? A의 각 row들을 w을 컬럼들과 한번씩 곱하야하기 때문에 3 by 4 matrix가 생성된다. 그렇다면 계산은 어떻게 될까? 해당 column과 row를 sum product해서 돌바른 자리에 넣어주면 된다. 위의 계산 예시를 참고. 여기서, Multiplication을 하기위한..
-
Matrix Multiplication | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 2. 10. 06:05
Coursera Machine Learning Specialization > Supervised Machine Learning: Advanced Learning Algorithms > Neural Network Intuition 지난시간, for loop을 이용하는것보다 vectorization을 통해서 2D Array, 즉 Matrix를 이용하면 훨씬 코드를 간단하게 만들 수 있었다. 그렇다면 이 Matrix를 곱한다는것은 어떤 의미일까? Linear Algibra 수업으로 되돌아가보자. 간단한 예시이다. 2개의 Vector를 dot product하게 되면, 간단하게 같은 층에 있는 값들끼리 곱해서 더하게 된다. 이런식의 행렬같은 경우, 같은 위치에 있는 값들을 모두 곱해서 더하는 방식인데, 이런것을 ..
-
How Neural Networks are Implemented Efficiently(Feat. mutmul) | Advanced Learning AlgorithmMachine Learning/Stanford ML Specialization 2024. 2. 10. 05:14
지난 10년동안 Neural Network 분야가 급속도로 성장할 수 있었던 이유중 하나는, 이 신경망을 Vector화 할 수 있었기 때문이다. Matrix(행렬) 곱셈을 사용하면 이 모델을 아주 효율적으로 구현할 수 있다. GPU를 포함한 병렬 컴퓨팅 하드웨어뿐만 아니라, 일부 CPU도 아주 큰 Matrix 곱셈을 수행할 때 아주 능숙하다는 것이 밝혀졌다. 이런 벡터화된 신경망 구현이 어떻게 작동하는지 알아보자. 먼저, loop들과 vectorization을 비교해보자. 먼저, 단일 레이어에서 Forward Propagation을 구현하는 방법을 살펴보자. x = np.array([200, 17]) W = np.array([[1, -3, 5], [-2, 4, -6]]) b = np.array([-1, ..