반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 웹 용어
- mglearn
- 결합전문기관
- web 용어
- 재귀함수
- broscoding
- paragraph
- tensorflow
- CES 2O21 참가
- vscode
- postorder
- html
- 데이터전문기관
- pycharm
- discrete_scatter
- 대이터
- web 개발
- web 사진
- KNeighborsClassifier
- java역사
- C언어
- Keras
- 머신러닝
- web
- bccard
- classification
- inorder
- 자료구조
- cudnn
- CES 2O21 참여
Archives
- Today
- Total
bro's coding
tensorflow.분류.mnist 본문
반응형
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist=input_data.read_data_sets('./mnist/data/',one_hot=True)
# mnist 분류
# RMSPropOptimizer
X=tf.placeholder(tf.float32,shape=(None,784))
y=tf.placeholder(tf.float32,shape=(None,10))
w=tf.Variable(tf.random.normal([784,10],0,0.1))
b=tf.Variable(tf.random.normal([10],0,0.1))
pred_y=X@w+b
##
entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=y,logits=pred_y))
##
optimizer=tf.train.RMSPropOptimizer(learning_rate=0.01)
train_op=optimizer.minimize(entropy)
costs=[]
sess=tf.InteractiveSession()
tf.global_variables_initializer().run()
from sklearn.model_selection import train_test_split
X_trian,X_test,y_train,y_test=train_test_split(iris.data,np.eye(3)[iris.target])
for i in range(300):
entropy_val,_=sess.run([entropy,train_op],feed_dict={X:mnist.train.images,y:mnist.train.labels})
costs.append(entropy_val)
import matplotlib.pyplot as plt
plt.plot(costs)
entropy_val,_=sess.run([entropy,train_op],feed_dict={X:mnist.test.images,y:mnist.test.labels})
pred_yyy=pred_y.eval(feed_dict={X:mnist.test.images,y:mnist.test.labels})
score=(pred_yyy.argmax(axis=1)==mnist.test.labels.argmax(axis=1)).mean()
score
0.9235
ww=w.eval()
plt.figure(figsize=[10,10])
for i in range(10):
plt.subplot(2,5,i+1)
plt.title(i)
plt.imshow(ww[:,i].reshape(-1,28))
반응형
'[AI] > python.tensorflow' 카테고리의 다른 글
tensorflow.AUTOTUNE (0) | 2020.06.15 |
---|---|
tensorflow.mnist.초급 (0) | 2020.06.12 |
tensorflow.distinguish mnist (0) | 2020.06.11 |
tensorflow.mnist (0) | 2020.05.12 |
tensorflow.분류(중간층) (0) | 2020.05.12 |
tensorflow.분류(중간층).relu,sigmoid 비교 (0) | 2020.05.12 |
tensorflow.분류(중간층X) (0) | 2020.05.12 |
tensorflow.placeholder (0) | 2020.05.11 |
Comments