Tensorflow機械学習データは、エントリを識別するために設定し--MINIST

参考サイト:http://www.tensorfly.cn/tfdoc/tutorials/mnist_beginners.html

自動的にデータをダウンロードし、ローディング
から tensorflow.examples.tutorials.mnist インポートINPUT_DATA 
MNIST = input_data.read_data_sets(" MNIST_data / "、one_hot = TRUE) 

構成図算出
インポートAS tensorflowのTF 
X = tf.placeholder(" フロート"、[いずれも、784 ])
Y_ = tf.placeholder(" フロート"、[なし]、10 ])
Wは = tf.Variable(tf.zeros([784,10 )])
B = tf.Variable(tf.zeros([10 ]))
Y = tf.nn.softmax(tf.matmul(X、Wは)+B)
cross_entropy = -tf.reduce_sum(Y_ * tf.log(Y))
train_step = tf.train.GradientDescentOptimizer(0.01 ).minimize(cross_entropy) 

训练千步 
INIT = tf.initialize_all_variables()
のSES = tf.Session( )
sess.run(INIT)
のための I における範囲(1000 ):
  batch_xs、batch_ys = mnist.train.next_batch(100 
  sess.run(train_step、feed_dict = {X:batch_xs、Y_:​​batch_ys}) 
 
验证准确率 
correct_prediction = tf.equal(tf.argmax(Y、1)、tf.argmax(Y_、1 ))
精度= tf.reduce_mean(tf.cast(correct_prediction、" フロート" ))
 プリント(sess.run(精度、feed_dict = {X:mnist.test.images、Y_:​​mnist.test.labels}))

 

おすすめ

転載: www.cnblogs.com/Fengqiao/p/MINIST.html