tensorflow 2.0 예제 dataset 소개(MNIST) 및 불러오기 (19:12)
# tensorflow data loading
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
%matplotlib inline
from tensorflow.keras import datasets
mnist = datasets.mnist
(train_x, train_y), (test_x, test_y) = mnist.load_data()
# 데이터 들여다보기
train_x.shape
# >> (60000, 28, 28)
# 데이터 하나만 뽑기
image = train_x[0]
image.shape
# >> (28,28)
# 시각화해서 확인
plt.imshow(image, 'gray')
plt.show()
# >> 숫자 5 image
# channel 관련
# 데이터 차원수 늘리기(numpy)
expanded_data = np.expand_dims(train_x, -1)
expanded_data.shape
# >> (1,60000,28,28)
# tensorflow 차원수 늘리기
new_train_x = tf.expaned_dims(train_x, -1)
new_train_x.shape
'DS > fast campus daily report' 카테고리의 다른 글
7.25 (딥러닝 인공지능) numpy 기초 - 1 (0) | 2020.07.25 |
---|---|
7.24 (딥러닝 인공지능) anaconda 활용 및 단축키, tensor 이해하기 (0) | 2020.07.24 |
7.19 (머신러닝과 데이터분석) oversampling 기법, SMOTE변형 기법들 (0) | 2020.07.19 |
7.18 (머신러닝과 데이터분석)class imbalanced problem>imbalanced problem 해결방법 (10:45) (0) | 2020.07.19 |
7.15 (머신러닝과 데이터분석) k-means 1.clustering, 2.k-means clustering, 3.최적의 k (0) | 2020.07.15 |