일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
- Deep
- mysql
- DeepLearning
- SSH
- mariaDB
- Pattern
- Linux
- java
- Web
- Python
- interface
- 함수
- LIST
- Analysis
- 인공지능
- ai
- Security
- db
- Server
- javascript
- learning
- data
- Github
- 자바
- Numpy
- centos
- Spring
- git
- framework
- error
- Today
- Total
PostIT
[AI/Deep Learing] Deep Learning 준비하기 - MNIST Load Data - 5-1 본문
[AI/Deep Learing] Deep Learning 준비하기 - MNIST Load Data - 5-1
shun10114 2017. 6. 23. 15:58# [AI/Deep Learing] Deep Learning 준비하기 - MNIST Load Data - 5-1
import sys, os
sys.path.append(os.pardir)
import numpy as np
import pickle
from dataset.mnist import load_mnist
from common.functions import sigmoid, softmax
def get_data():
(x_train, t_train), (x_test, t_test) = load_mnist(normalize=True, flatten=True, one_hot_label=False)
return x_test, t_test
def init_network():
with open("sample_weight.pkl", 'rb') as f:
network = pickle.load(f)
return network
def predict(network, x):
W1, W2, W3 = network['W1'], network['W2'], network['W3']
b1, b2, b3 = network['b1'], network['b2'], network['b3']
a1 = np.dot(x, W1) + b1
z1 = sigmoid(a1)
a2 = np.dot(z1, W2) + b2
z2 = sigmoid(a2)
a3 = np.dot(z2, W3) + b3
y = softmax(a3)
return y
x, t = get_data()
network = init_network()
accuracy_cnt = 0
for i in range(len(x)):
y = predict(network, x[i])
p= np.argmax(y)
# 확률이 가장 높은 인덱스 값을 가져옴.
if p == t[i]:
accuracy_cnt += 1
print("Accuracy:" + str(float(accuracy_cnt) / len(x)))
Accuracy:0.9352
x, _ = get_data()
network = init_network()
W1, W2, W3 = network['W1'], network['W2'], network['W3']
x.shape
(10000, 784)
x[0].shape
(784,)
W1.shape
(784, 50)
W2.shape
(50, 100)
W3.shape
(100, 10)
'Deep Learning' 카테고리의 다른 글
[AI/Deep Learing] Deep Learning 준비하기 - MNIST DataSet - 5 (0) | 2017.06.23 |
---|---|
[AI/Deep Learing] Deep Learning 준비하기 - 순방향 3층 신경망 구현 - 4 (0) | 2017.06.23 |
[AI/Deep Learing] 인공지능을 위한 Deep Learning 준비(다차원 배열의 계산) - 3 (0) | 2017.05.31 |
[AI/Deep Learing] 인공지능을 위한 Deep Learning 준비(시그모이드 & ReLU 함수 구현하기) - 2 (0) | 2017.05.31 |
[AI/Deep Learing] 인공지능을 위한 Deep Learning 맛 보기 공부(Perceptron과 신경망) - 1 (0) | 2017.05.24 |