Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
add jupyter-notebook compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
keon committed May 19, 2018
1 parent c60a08d commit 245822c
Show file tree
Hide file tree
Showing 23 changed files with 1,788 additions and 383 deletions.
7 changes: 7 additions & 0 deletions 01-Deep-Learning-And-PyTorch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 딥러닝과 파이토치

딥러닝의 기본 지식을 쌓고 파이토치의 장단점에 대해 알아봅니다.

* [개념] 신경망의 원리
* [개념] 딥러닝과 신경망
* [개념] 왜 파이토치인가?
7 changes: 7 additions & 0 deletions 02-Getting-Started-With-PyTorch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 파이토치 시작하기

파이토치 환경설정과 사용법을 익혀봅니다

* [프로젝트 1] 파이토치 설치 & 환경구성
* [프로젝트 2] 파이토치 예제 내려받고 실행해보기
* [프로젝트 3] 토치비전과 토치텍스트로 데이터셋 불러오기
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions 03-Coding-Neural-Networks-In-PyTorch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 파이토치로 구현하는 신경망

파이토치를 이용하여 가장 기본적인 신경망을 만들어봅니다.

* [개념] 텐서와 Autograd
* [Hello World] 신경망 모델 구현하기
* [Hello World] 모델 저장, 재사용
File renamed without changes.
442 changes: 442 additions & 0 deletions 04-Neural-Network-For-Fashion/01-fashion-mnist.ipynb

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions 04-Neural-Network-For-Fashion/01-fashion-mnist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@

# coding: utf-8

# # 4.1 Fashion MNIST 데이터셋 알아보기

get_ipython().run_line_magic('matplotlib', 'inline')
from torchvision import datasets, transforms, utils
from torch.utils import data

import matplotlib.pyplot as plt
import numpy as np


# ## [개념] Fashion MNIST 데이터셋 설명

transform = transforms.Compose([
transforms.ToTensor()
])


trainset = datasets.FashionMNIST(
root = './.data/',
train = True,
download = True,
transform = transform
)
testset = datasets.FashionMNIST(
root = './.data/',
train = False,
download = True,
transform = transform
)


batch_size = 16

train_loader = data.DataLoader(
dataset = trainset,
batch_size = batch_size,
shuffle = True,
num_workers = 2
)
test_loader = data.DataLoader(
dataset = testset,
batch_size = batch_size,
shuffle = True,
num_workers = 2
)


dataiter = iter(train_loader)
images, labels = next(dataiter)


# ## 멀리서 살펴보기
# 누군가 "숲을 먼저 보고 나무를 보라"고 했습니다. 데이터셋을 먼저 전체적으로 살펴보며 어떤 느낌인지 알아보겠습니다.

img = utils.make_grid(images, padding=0)
npimg = img.numpy()
plt.figure(figsize=(10, 7))
plt.imshow(np.transpose(npimg, (1,2,0)))
plt.show()


CLASSES = {
0: 'T-shirt/top',
1: 'Trouser',
2: 'Pullover',
3: 'Dress',
4: 'Coat',
5: 'Sandal',
6: 'Shirt',
7: 'Sneaker',
8: 'Bag',
9: 'Ankle boot'
}

KR_CLASSES = {
0: '티셔츠',
1: '바지',
2: '스웨터',
3: '드레스',
4: '코트',
5: '샌들',
6: '셔츠',
7: '운동화',
8: '가방',
9: '앵클부츠'
}

for label in labels:
index = label.item()
print(KR_CLASSES[index])


# ## 가까이서 살펴보기
# 또 누군가는 "숲만 보지 말고 나무를 보라"고 합니다. 이제 전체적인 느낌을 알았으니 개별적으로 살펴보겠습니다.

idx = 0

item_img = images[idx]
item_npimg = img.squeeze().numpy()
plt.title(CLASSES[labels[idx].item()])
plt.imshow(item_npimg, cmap='gray')
plt.show()


img.size()


img.max()


img.min()


img

Loading

0 comments on commit 245822c

Please sign in to comment.