일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- linalg
- scatter
- type hints
- 정규분포 MLE
- 표집분포
- Comparisons
- Numpy data I/O
- VSCode
- python 문법
- BOXPLOT
- Python
- 딥러닝
- Operation function
- Python 유래
- 가능도
- groupby
- Array operations
- unstack
- ndarray
- dtype
- 부스트캠프 AI테크
- pivot table
- subplot
- 카테고리분포 MLE
- 최대가능도 추정법
- boolean & fancy index
- seaborn
- Numpy
- namedtuple
- Python 특징
- Today
- Total
목록부스트캠프 AI 테크 U stage/실습 (40)
또르르's 개발 Story

Knowledge Distillation의 대표격인 Teacher-Student network를 만들어봅니다. ref) github.com/kmsravindra/ML-AI-experiments/blob/master/AI/knowledge_distillation/Knowledge%20distillation.ipynb 1️⃣ 설정 필요한 모듈을 import합니다. # import import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F from torch.optim import lr_scheduler from torchsummary import summary import torchvision im..

1️⃣ 설정 모델은 ResNet18, 데이터는 Mnist를 사용합니다. ResNet18에 대한 model의 PERFORMANCE는 다음과 같습니다. 2️⃣ Dynamic Quantization Dynamic Quantization은 모델의 weight를 quantize 하고, inference 때 레이어의 출력 activation을 더 dynamically quantize (int8) 하게 됩니다. Dynamic Quantization은 int8 연산 수행(이때 해당 결과는 float32의 형태로 나오는 것을 허용) -> 결과물을 int8로 변환 -> 다시 연산 수행의 과정을 거치게 됩니다. 학습된 모델의 Linear 레이어를 quantize_dynamic로 활용하여 quantizing 해보겠습니다. (..

Pruning을 수행하기 위한 간단한 모델을 생성하고 훈련합니다. 모델은 LeNet5, 데이터는 Mnist를 사용합니다. 자세한 내용은 Pytorch pruning tutorial를 참고해주세요. Pruning Tutorial — PyTorch Tutorials 1.8.0 documentation Note Click here to download the full example code Pruning Tutorial Author: Michela Paganini State-of-the-art deep learning techniques rely on over-parametrized models that are hard to deploy. On the contrary, biological neural netw..

Python에서 어떤 task를 병렬 처리로 실행하기 위해서는 Ray module을 사용합니다. Ray module은 remote function을 사용해서 task들을 비동기적으로 처리할 수 있습니다. 1️⃣ 설정 Ray module을 설치해줍니다. # install ray !pip install ray ray module을 init 해줍니다. import ray import time # Check node ray.init() 2021-03-17 06:26:32,365INFO services.py:1174 -- View the Ray dashboard at http://127.0.0.1:8265 {'metrics_export_port': 59846, 'node_id': '5557bc90a7c69d388..
PyTorch profiler는 컴퓨팅 자원의 사용량 모니터링할 수 있는 모듈입니다. reference: https://pytorch.org/tutorials/recipes/recipes/profiler.html https://pytorch.org/tutorials/recipes/recipes/profiler.html pytorch.org 1️⃣ 설정 필요한 모듈을 불러옵니다. import torch import torchvision.models as models import torch.autograd.profiler as profiler Pre-trained 된 모델을 불러오고, random값으로 구성된 input을 만듭니다. model = models.resnet18() inputs = torch.r..

Model Conversion은 하나의 모델을 여러 Library로 변경하는 방법을 뜻합니다. 아래 그림과 같이 pytorch (.pth)로 pre-trained된 alexnet을 불러온다고 할 때 ONNX (.onnx) -> Tensorflow (.pb) Tensorflow (.pb) -> tensorrt (.trt) PyTorch (.pth) -> ONNX (.onnx) ONNX (.onnx) -> PyTorch (.pth) ONNX (.onnx) -> Keras (.h5) Tensorflow (.pb) -> Tensorflowlite (.tflite) 로 변경할 수 있습니다. 즉, 대부분 ONNX 형식으로 변환 후 Model을 conversion 할 수 있습니다. 1️⃣ 설정 Onnx, tensor..

Hourglass Network는Landmark Localization의 대표적인 Network입니다. 이 코드는 basic code이며, 전체 코드는 링크에서 볼 수 있습니다. 1️⃣ 설정 필요한 모듈을 import 합니다. # Seed import torch import numpy as np import random torch.manual_seed(0) torch.cuda.manual_seed(0) np.random.seed(0) random.seed(0) # Ignore warnings import warnings warnings.filterwarnings('ignore') 2️⃣ Hourglass 모듈 Hourglass Network는 Hourglass 모듈의 stack으로 구성되어 있고, Hou..

Pre-trained된 VGG11을 backbone network로 사용해서 visualization을 할 수 있습니다. 1️⃣ Visualizing model activations hook을 사용해서 중간에 있는 layer에 있는 activation map을 추출할 수 있습니다. 1) Plot_filters 함수 plot_filters함수는 weight들의 data를 시각화해주는 function입니다. def plot_filters(data, title=None): """ Take a Tensor of shape (n, K, height, width) or (n, K, height, width) and visualize each (height, width) thing in a grid of size a..

1️⃣ Autograd Automatic gradient의 약자로 자동 미분을 뜻합니다. Autograd는 자동으로 forward & backward passes를 가능하게 만들어줍니다. 즉, 학습을 하면서 많은 parameter를 사용했다면 backpropagation을 하면서 자동으로 gradient를 계산해줍니다. Autograd는 Computational graph라는 데이터 구조를 사용해서 automatic gradient를 편리하게 구현할 수 있도록 만들었습니다. $c$는 $w_2$와 $a$의 operation으로 계산됨 $b$는 $w_1$과 $a$의 operation으로 계산됨 $d$는 $c$와 $b$와 $w_4$, $w_3$의 operation으로 계산됨 $L$은 $d$의 operation..

VGG-11 CNN 모델을 segmentation 문제를 풀기 위한 모델로 바꾸는 과정입니다. 1️⃣ VGG-11 BackBone VGG-11의 기본 CNN 모델을 만듭니다. BackBone은 Classification과 Segmentation을 구성하는 "뼈대" 모델을 의미하며, feature map을 추출하는 역할을 합니다. VGG11BackBone 코드는 다음과 같습니다. import torch import torch.nn as nn class VGG11BackBone(nn.Module): def __init__(self): super(VGG11BackBone, self).__init__() self.relu = nn.ReLU(inplace=True) # Convolution Feature Extr..