공부하며 성장하기/인공지능 AI
![[한 줄 정리] 다양한 Normalization 기법들](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FBPi5t%2FbtsEQbAQPDv%2FKvpe76sFY6Wk3LCzdp0oCK%2Fimg.png)
[한 줄 정리] 다양한 Normalization 기법들
가장 흔히 사용하는 Batch Normalization 외에도, Layer Normalization, Instance Normalization, Group Normalization이 있다. Batch Normalzation과 비교해 각각 간단히, 직관적으로 정리해 보았다. 우선 Batch Norm은 하나의 batch 내 모든 이미지를 channel별로 normalize 하는 것이다. 아래 그림에는 한 배치당 2개 이미지가 있고, 각 채널 개수는 3이다. 그런데 이 BN에 작은 단점이 있다. batch 내에 엄청 튀는 data가 있으면 그에 편향된 평균과 표준편차로 normalize 된다는 것이다. 물론 batch size를 키우면 대부분 해결이 된다. 하지만 그게 어려울 경우, batch와 관계없이 no..
![Object Detection에서 mAP_0.5와 mAP_0.5:0.95의 의미](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FryDLu%2FbtsB1FZfg8I%2FeCR909sC9HZIvbKSzPf8nk%2Fimg.png)
Object Detection에서 mAP_0.5와 mAP_0.5:0.95의 의미
Object Detection 모델을 학습하면서 mAP_0.5는 꽤 높은 수준으로 잘 나오는데, mAP_0.5:0.95는 그에 비해 많이 떨어지는 걸 발견했다. 표기만 봐서는 mAP_0.5는 IoU 값이 0.5 이상일 때 Average Precision의 평균일 거고, mAP_0.5:0.95는 IoU 값이 0.5에서 0.95 사이인 경우 Average Precision의 평균일텐데, 왜 이렇게 차이가 많이 나는지 이해가 가지 않았다. 정확히 찾아보니, mAP_0.5:0.95는 0.05 step으로 IoU 값이 0.5일 때, 0.55일 때, 0.6, 0.65, 0.70, ..., 0.9, 0.95일 때 Average Precision을 각각 구한 후 그 평균을 구한 값임을 알았다. 당연히 IoU thres..
![DeeplabV3+ 모델 전이 학습(transfer learning) 쉽게 구현하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fv0QNw%2FbtsjYtv0olk%2FHwx89skzmDqaiJGgKOcJw0%2Fimg.png)
DeeplabV3+ 모델 전이 학습(transfer learning) 쉽게 구현하기
아래 repository를 기반으로 작성하였다. GitHub - qubvel/segmentation_models.pytorch: Segmentation models with pretrained backbones. PyTorch. Segmentation models with pretrained backbones. PyTorch. - GitHub - qubvel/segmentation_models.pytorch: Segmentation models with pretrained backbones. PyTorch. github.com 1. Pretrained 모델 로드 # train.py pretrained_model = smp.DeepLabV3Plus( encoder_name='resnet50', encode..
![AMP(Automatic Mixed Precision) 쉽게 적용하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FsOdXx%2FbtsjYdTunr3%2FgvlKY3I3kVw6LfkYAkZnXK%2Fimg.png)
AMP(Automatic Mixed Precision) 쉽게 적용하기
pytorch 1.6 이상에서는 torch.cuda.amp 패키지를 이용해 편리하게 AMP를 적용할 수 있다. * AMP는 float32와 float16을 함께 적절히 사용함으로써 빠른 연산 속도와 효율적인 메모리 활용이 가능하도록 해준다. 내 딥러닝 모델에 AMP를 적용하려면 앞서 말한 패키지에서 두 가지를 import 해야 한다. from torch.cuda.amp import autocast, GradScaler 우선 GradScaler는 mixed-precision으로 학습을 진행할 때 gradient scaling을 수행하는 역할을 한다. 즉 backpropagation 중 gradient가 너무 작아지는 것을 방지하여 floating-point 형식으로 정확하게 표현될 수 없는 숫자가 되는 문..
![K-means Clustering](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FGW8IP%2FbtsgQp94oIx%2FYJSFy85H8jPJ29bBBk6A2k%2Fimg.png)
K-means Clustering
K-means cluster analysis is an unsupervised machine learning algorithm used to partition a dataset into distinct groups or clusters based on similarity of data points. It aims to find K cluster centers in such a way that the within-cluster sum of squares is minimized. Here's how k-means cluster analysis works: Initial Setup: The algorithm begins by randomly selecting K initial cluster centers fr..
![Lasso regression](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbs4bzW%2FbtsgE64UeRf%2FatpUlPnIxxYP2fJxw4BtO0%2Fimg.png)
Lasso regression
Lasso regression, also known as L1 regularization, is a linear regression technique that incorporates regularization to prevent overfitting and improve the model's interpretability. It adds a penalty term to the standard least squares objective function, which encourages the model to select only a subset of the available features by shrinking the coefficients of irrelevant or less important feat..
Random Forest
The concept of a random forest is a popular machine learning technique used for both classification and regression tasks. It is an ensemble method that combines multiple decision trees to make predictions. Here's how a random forest works: Data Preparation: The first step is to prepare the training data, which includes input features and corresponding labels or target values. Each instance in th..
![Decision Tree](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fb9VBeS%2FbtsgBPDeyPE%2FSGpxcr9Ma6rG2eiXufPyT1%2Fimg.png)
Decision Tree
A decision tree is a supervised machine learning algorithm that is used for both classification and regression tasks. It is a flowchart-like structure where each internal node represents a feature or attribute, each branch represents a decision rule, and each leaf node represents the outcome or class label. The concept of a decision tree is based on a series of binary decisions that lead to a fi..
![초기 신경망 이론과 모델](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FF8LqZ%2FbtrPti4Qxcx%2FUl1kbkLD6ua25bvcqpxj6k%2Fimg.png)
초기 신경망 이론과 모델
현재의 딥러닝 구조와 방식을 더 깊게 이해하기 위해 초기 신경망 이론과 모델에 대해 정리해 보았다. 1943년 맥컬럭-피츠(McCulloch-Pitts) 뉴런 맥컬럭과 피츠는 최초로 인간 두뇌의 뉴런을 모델링했다. 그 바탕에는 '인간의 두뇌는 논리적 서술을 구현하는 이진 원소들의 집합'이라는 추측이 있었다. 신경 활동의 '전부 아니면 전무(All-or-nothing)'적인 특성 때문에 신경계의 일과 그들 사이의 관계들은 명제 논리(Propositional logic)로 취급된다. 모든 망의 행동은 이러한 관점에서 기술될 수 있다. (중략) 어떠한 조건들을 만족시키려는 논리적 표현에 대하여, 우리는 그것이 기술하는 방법대로 행동하는 망을 찾을 수 있다. 즉 어떠한 논리적 명제에 대하여 참(True) 혹은 ..
![이미지 인코딩(Encoding)과 디코딩(Decoding) 과정 이해하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FJiEj4%2FbtrOYodtmzk%2FMfAXM99nA1W2N5gUuuJJf1%2Fimg.png)
이미지 인코딩(Encoding)과 디코딩(Decoding) 과정 이해하기
보통 인코딩(Encoding)이라 하면, 문자를 컴퓨터가 이해할 수 있도록 바이너리 숫자 정보로 변환하는 것을 말한다. 이때 변환의 기준이 되는 것이 바로 ASCII, 유니코드 같은 형식들이다. 이렇게 데이터를 인코딩함으로써 다음 3 가지 측면에서 이점을 얻을 수 있다: ① 보안, ② 처리 속도 향상, ③ 저장 공간 절약. 이미지 데이터를 로드하는 방법에는 여러 가지가 있지만, 가장 자주 사용하게 되는 방식은 다음과 같이 file 또는 buffer로부터 이미지를 디코딩하는 방식이다. PIL, cv2.imread, pyplot 등 다양한 라이브러리와 메서드를 비교해봤을 때 아래와 같은 방식이 가장 속도가 빠르고, 특히 cv2에서 한글로 된 파일명으로 인해 발생하는 오류를 방지할 수 있기 때문이다. # 파일..