{"id":9517,"date":"2016-06-28T14:48:59","date_gmt":"2016-06-28T05:48:59","guid":{"rendered":"http:\/\/www.itblog.jp\/?p=9517"},"modified":"2016-07-10T15:26:34","modified_gmt":"2016-07-10T06:26:34","slug":"mnist-for-ml-beginners%e3%81%ae%e5%92%8c%e8%a8%b3","status":"publish","type":"post","link":"https:\/\/www.itblog.jp\/?p=9517","title":{"rendered":"MNIST For ML Beginners\u306e\u548c\u8a33"},"content":{"rendered":"<p>Tensorflow\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3068\u3082\u3044\u3048\u308b\u300cMNIST For ML Beginners\u300d\u306e\u82f1\u6587\u306b\u3064\u3044\u3066\u3001\u6a5f\u68b0\u5b66\u7fd2\u521d\u5fc3\u8005\u3068\u3044\u3046\u3053\u3068\u3067\u307e\u305a\u6587\u7ae0\u3092\u548c\u8a33\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.tensorflow.org\/versions\/r0.9\/tutorials\/mnist\/beginners\/index.html#mnist-for-ml-beginners\">\u516c\u5f0f\u30b5\u30a4\u30c8\uff08\u82f1\u8a9e\uff09\u306f\u3053\u3061\u3089<\/a><\/p>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306f\u3001\u6a5f\u68b0\u5b66\u7fd2\u3068TensorFlow\u306e\u521d\u5fc3\u8005\u5411\u3051\u306e\u5185\u5bb9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3082\u3057\u3042\u306a\u305f\u304cMNIST\u304c\u4f55\u304b\u3092\u77e5\u3063\u3066\u3044\u3066\u3001\u591a\u6b21\u5143\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30(\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30)\u304c\u4f55\u304b\u3092\u77e5\u3063\u3066\u3044\u308b\u306e\u3067\u3042\u308c\u3070\u3001\u3053\u3061\u3089\u306e<a href=\"https:\/\/www.tensorflow.org\/versions\/r0.9\/tutorials\/mnist\/pros\/index.html\">\u4e0a\u7d1a\u8005\u5411\u3051\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/a>\u306e\u307b\u3046\u304c\u3088\u3044\u3067\u3057\u3087\u3046\u3002<br \/>\n\u3069\u3061\u3089\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306b\u3057\u3066\u3082\u3001\u4e8b\u524d\u306b<a href=\"https:\/\/www.tensorflow.org\/versions\/r0.9\/get_started\/os_setup.html\">Tensor Flow<\/a>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3064\u3044\u3066\u52c9\u5f37\u3059\u308b\u3068\u304d\u306b\u306f\u3001\u307e\u305a\u6700\u521d\u306b\u300cHello World\u300d\u3092\u51fa\u529b\u3059\u308b\u4f1d\u7d71\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u6a5f\u68b0\u5b66\u7fd2\u3067\u306fMNIST\u304cHello World\u306b\u76f8\u5f53\u3057\u307e\u3059\u3002<\/p>\n<p>MNIST\u306f\u30b7\u30f3\u30d7\u30eb\u306a\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u305f\u3081\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067\u3059\u3002<br \/>\n\u305d\u308c\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u624b\u66f8\u304d\u6587\u5b57\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/MNIST.png\" alt=\"\u624b\u66f8\u304d\u6587\u5b57\" class=\"alignnone size-full wp-image-9518\" width=\"100%\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/MNIST.png 636w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/MNIST-300x75.png 300w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/p>\n<p>\u307e\u305f\u3001\u3053\u306e\u6587\u5b57\u30bb\u30c3\u30c8\u306f\u305d\u308c\u305e\u308c\u306e\u753b\u50cf\u306b\u5bfe\u3057\u3066\u3001\u305d\u306e\u6587\u5b57\u304c\u4f55\u3067\u3042\u308b\u304b\u3092\u793a\u3059\u30e9\u30d9\u30eb\u3092\u542b\u3093\u3067\u3044\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u4e0a\u8a18\u306e\u753b\u50cf\u306b\u5bfe\u3057\u3066\u306e\u30e9\u30d9\u30eb\u306f5,0,4,1\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001\u30e2\u30c7\u30eb\u3092\u6587\u5b57\u304c\u4f55\u3067\u3042\u308b\u304b\u3092\u4e88\u6e2c\u3067\u304d\u308b\u3088\u3046\u306b\u8a13\u7df4\u3057\u307e\u3059\u3002<br \/>\n\u76ee\u7684\u3068\u3057\u3066\u306f\u3001\u6700\u5148\u7aef\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u9054\u6210\u3059\u308b\u7cbe\u5de7\u306a\u30e2\u30c7\u30eb\u3092\u8a13\u7df4\u3059\u308b\u3053\u3068\u3067\u306f\u306a\u304f\uff08\u3042\u3068\u3067\u30b3\u30fc\u30c9\u3092\u63d0\u4f9b\u3057\u307e\u3059\uff09\u304c\u3001TensorFlow\u3092\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u3067\u3059\u3002<br \/>\n\u305d\u306e\u3088\u3046\u306a\u3082\u306e\u3068\u3057\u3066\u3001\u3068\u3066\u3082\u5358\u7d14\u306a\u30e2\u30c7\u30eb\u3067\u591a\u6b21\u5143\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30(\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30)\u3068\u547c\u3070\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u4f7f\u7528\u3059\u308b\u30b3\u30fc\u30c9\u306f\u3068\u3066\u3082\u77ed\u304f\u3001\u305f\u3063\u305f\u4e09\u884c\u3067\u8208\u5473\u6df1\u3044\u3053\u3068\u304c\u304a\u304d\u307e\u3059\u3002<br \/>\n\u3057\u304b\u3057\u306a\u304c\u3089\u3001\u80cc\u666f\u306b\u3042\u308b\u3068\u3066\u3082\u91cd\u8981\u306a\u30a2\u30a4\u30c7\u30a2\uff08TensorFlow\u304c\u3069\u3046\u3084\u3063\u3066\u52d5\u4f5c\u3057\u3066\u3044\u308b\u304b\u3068\u3001\u6a5f\u68b0\u5b66\u7fd2\u306e\u4e2d\u6838\u3068\u306a\u308b\u30b3\u30f3\u30bb\u30d7\u30c8\uff09\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<br \/>\n\u3053\u306e\u305f\u3081\u3001\u30b3\u30fc\u30c9\u306b\u5bfe\u3057\u3066\u6ce8\u610f\u6df1\u304f\u7406\u89e3\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>MNIST\u306e\u30c7\u30fc\u30bf<\/h3>\n<p>MNIST\u306e\u30c7\u30fc\u30bf\u306f\u3001<a href=\"https:\/\/yann.lecun.com\/exdb\/mnist\/\">Yann LeCun\u6c0f\u306e\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8<\/a>\u306b\u30db\u30b9\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u7c21\u5358\u306b\u3059\u308b\u305f\u3081\u3001\u81ea\u52d5\u7684\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3044\u304f\u3064\u304b\u306epython\u306e\u30b3\u30fc\u30c9\u3092\u8e0f\u3093\u3067\u3044\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u304b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5358\u7d14\u306b\u30b3\u30d4\u30fc&#038;\u30da\u30fc\u30b9\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>from tensorflow.examples.tutorials.mnist import input_data<br \/>\nmnist = input_data.read_data_sets(&#8220;MNIST_data\/&#8221;, one_hot=True)<\/p>\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30c7\u30fc\u30bf\u306f3\u3064\u306e\u30d1\u30fc\u30c8\u306b\u5206\u304b\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n55,000\u306e\u8a13\u7df4\u7528\u306e\u30c7\u30fc\u30bf(mnist.train)\u300110,000\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf(mnist.test)\u3001\u305d\u3057\u30665000\u306e\u6b63\u898f\u5316\u30c7\u30fc\u30bf(mnist.validation)\u3067\u3059\u3002<br \/>\n\u3053\u306e\u533a\u5206\u306f\u3068\u3066\u3082\u91cd\u8981\u3067\u3001\u305d\u308c\u306f\u6a5f\u68b0\u5b66\u7fd2\u306b\u5fc5\u8981\u4e0d\u53ef\u6b20\u306a\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u6700\u521d\u306b\u3082\u8ff0\u3079\u305f\u3088\u3046\u306b\u3001MNIST\u30c7\u30fc\u30bf\u306f\uff12\u3064\u306b\u5206\u304b\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u624b\u66f8\u304d\u306e\u6587\u5b57\u3068\u5bfe\u5fdc\u3059\u308b\u30e9\u30d9\u30eb\u3067\u3059\u3002<br \/>\n\u3053\u306e\u753b\u50cf\u3092\u300cxs\u300d\u300cys\u300d\u3068\u547c\u3073\u3001\u8a13\u7df4\u7528\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3068\u30c6\u30b9\u30c8\u7528\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u4e21\u65b9\u306b\u542b\u3093\u3067\u3044\u307e\u3059\u3002<br \/>\n\u4f8b\u3068\u3057\u3066\u3001\u8a13\u7df4\u7528\u306e\u753b\u50cf\u3092\u300cmnist.train.images\u300d\u3001\u8a13\u7df4\u7528\u306e\u30c7\u30fc\u30bf\u306e\u30e9\u30d9\u30eb\u3092\u300cmnist.train.labels\u300d\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u305e\u308c\u306e\u753b\u50cf\u306f28\u00d728\u30d4\u30af\u30bb\u30eb\u3067\u3059\u3002<br \/>\n\u79c1\u305f\u3061\u306f\u3053\u308c\u3092\u5927\u304d\u306a\u6570\u5024\u306e\u914d\u5217\u3068\u89e3\u91c8\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/MNIST-Matrix.png\" alt=\"MNIST-Matrix\"  width=\"100%\" class=\"alignnone size-full wp-image-9519\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/MNIST-Matrix.png 982w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/MNIST-Matrix-300x118.png 300w\" sizes=\"(max-width: 982px) 100vw, 982px\" \/><\/p>\n<p>\u3053\u306e\u914d\u5217\u3092\u3001\u7dda\u5f62\u306e28\u00d728=784\u306e\u6570\u5024\u306b\u623b\u3057\u307e\u3059\u3002<br \/>\n\u914d\u5217\u3092\u6570\u5024\u306b\u623b\u3057\u3066\u3044\u308b\u306e\u306f\u3001\u753b\u50cf\u3068\u4e00\u81f4\u3057\u3066\u3044\u308b\u9650\u308a\u554f\u984c\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u3053\u306e\u89b3\u70b9\u306b\u3088\u308a\u3001MNIST\u306e\u753b\u50cf\u306f\u3001\u3068\u3066\u3082\u8c4a\u5bcc\u306a\u69cb\u9020\u4f53\uff08\u6ce8\u610f\uff1a\u8a08\u7b97\u7684\u306b\u5fb9\u5e95\u7684\u306a\u8996\u899a\u5316\uff09\u4ed8\u304d\u306e\u3001\u305f\u3060\u306e784\u6b21\u5143\u306e\u7dda\u5f62\u7a7a\u9593\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u3092\uff12D\u306e\u753b\u50cf\u306e\u69cb\u9020\u306e\u60c5\u5831\u306b\u623b\u3059\u3053\u3068\u306f\u826f\u304f\u306a\u3044\u3053\u3068\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\n\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u304c\u3053\u306e\u69cb\u9020\u3092\u5229\u7528\u3059\u308b\u3068\u304d\u6700\u9069\u306e\u65b9\u6cd5\u3067\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u5f8c\u534a\u3067\u3082\u4f7f\u7528\u3057\u307e\u3059\u3002<br \/>\n\u3057\u304b\u3057\u3053\u3053\u3067\u4f7f\u3046\u30b7\u30f3\u30d7\u30eb\u306a\u65b9\u6cd5\u304c\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30\u304b\u3068\u3044\u3046\u3068\u9055\u3044\u307e\u3059\u3002<\/p>\n<p>mnist.train.images\u306e\u7d50\u679c\u306f\u3001[55000,784]\u306e\u30c6\u30f3\u30bd\u30eb\uff08n\u6b21\u5143\u914d\u5217\uff09\u3067\u3059\u3002<br \/>\n\u6700\u521d\u306e\u753b\u50cf\u306e\u6b21\u5143\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u3001\uff12\u3064\u76ee\u306e\u305d\u308c\u305e\u308c\u306e\u753b\u50cf\u30d4\u30af\u30bb\u30eb\u306e\u6b21\u5143\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3067\u3059\u3002<br \/>\n\u305d\u308c\u305e\u308c\u306e\u30c6\u30f3\u30bd\u30eb\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u306f\u30010\u30681\u306e\u9593\u3067\u3042\u308a\u3001\u7279\u5b9a\u306e\u753b\u50cf\u306e\u7279\u5b9a\u306e\u30d4\u30af\u30bb\u30eb\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-xs-1024x463.png\" alt=\"mnist-train-xs\"  width=\"100%\" class=\"alignnone size-large wp-image-9520\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-xs-1024x463.png 1024w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-xs-300x136.png 300w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-xs.png 1498w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>MNIST\u306e\u30e9\u30d9\u30eb\u306f0\u301c9\u307e\u3067\u3067\u3001\u3069\u306e\u6570\u5b57\u304c\u3069\u306e\u753b\u50cf\u304b\u3092\u63cf\u3044\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u76ee\u7684\u3067\u306f\u3001\u30e9\u30d9\u30eb\u3092\u300cone-hot\u30d9\u30af\u30c8\u30eb\u300d\u3068\u307f\u306a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\non-hot\u30d9\u30af\u30c8\u30eb\u306f\u3001\u591a\u304f\u306e\u6b21\u5143\u30670\u3067\u3059\u304c\u3001\uff11\u306f\uff11\u3064\u306e\u6b21\u5143\u3067\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30b1\u30fc\u30b9\u3067\u3001n\u756a\u76ee\u306e\u6570\u5b57\u304c\u3001n\u756a\u76ee\u306e\u6b21\u5143\u3067\uff11\u3067\u3042\u308b\u30d9\u30af\u30c8\u30eb\u3067\u3042\u308b\u3068\u8868\u3057\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u30013\u306f[0,0,0,1,0,0,0,0,0,0]\u3067\u3059\u3002<br \/>\n\u7d50\u679c\u7684\u306b\u3001mnist.train.labels\u306f[55000, 10] \u306e\u914d\u5217\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-ys.png\" alt=\"mnist-train-ys\"  width=\"100%\" class=\"alignnone size-full wp-image-9521\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-ys.png 1460w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-ys-300x104.png 300w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnist-train-ys-1024x354.png 1024w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><\/p>\n<p>\u3053\u308c\u3067\u3001\u73fe\u5b9f\u7684\u306a\u30e2\u30c7\u30eb\u3092\u4f5c\u308b\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30<\/h2>\n<p>\u79c1\u305f\u3061\u306f\u3001MINST\u306e\u5168\u3066\u306e\u753b\u50cf\u304c0\u301c9\u307e\u3067\u306e\u6570\u5b57\u3067\u3042\u308b\u3053\u3068\u3092\u77e5\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u79c1\u305f\u3061\u306f\u3001\u753b\u50cf\u3092\u898b\u3066\u305d\u308c\u305e\u308c\u306e\u6570\u5b57\u306b\u78ba\u7387\u3092\u4e0e\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u3067\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u79c1\u9054\u306e\u30e2\u30c7\u30eb\u306f9\u306e\u753b\u50cf\u3092\u898b\u306680%\u30679\u3060\u3068\u3057\u307e\u3059\u3001\u3057\u304b\u30575%\u306e\u78ba\u7387\u30678\u306b\u306a\u308a\u3001\u5c11\u306a\u3044\u78ba\u7387\u3067\u4ed6\u306e\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u53e4\u5178\u7684\u306a\u30b1\u30fc\u30b9\u3067\u3001\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30\u304c\u81ea\u7136\u3067\u3001\u30b7\u30f3\u30f3\u30d7\u30eb\u306a\u30e2\u30c7\u30eb\u306e\u5834\u5408\u3067\u3059\u3002<br \/>\n\u3082\u3057\u3042\u306a\u305f\u304c\u8907\u6570\u306e\u7570\u306a\u308b\u3082\u306e\u78ba\u7387\u3092\u8a08\u7b97\u3057\u305f\u3044\u3068\u304d\u3001\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u3067\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<br \/>\n\u5f8c\u3067\u3001\u3088\u308a\u5ba3\u4f1d\u3055\u308c\u305f\u30e2\u30c7\u30eb\u3092\u8a13\u7df4\u3059\u308b\u3068\u304d\u3001\u6700\u7d42\u7684\u306b\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u306e\u968e\u5c64\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30\u306f\uff12\u3064\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u3059\u3002\u6700\u521d\u306b\u6b63\u3057\u3044\u30af\u30e9\u30b9\u306e\u5165\u529b\u306e\u30a8\u30d3\u30c7\u30f3\u30b9\u3092\u52a0\u3048\u3066\u3001\u30a8\u30d3\u30c7\u30f3\u30b9\u3092\u78ba\u7387\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n<p>\u7279\u5b9a\u306e\u30af\u30e9\u30b9\u306e\u753b\u50cf\u304b\u3089\u4e0e\u3048\u3089\u308c\u305f\u30a8\u30d3\u30c7\u30f3\u30b9\u306e\u8a08\u7b97\u3092\u3059\u308b\u3053\u3068\u3067\u3001\u3044\u304f\u3064\u304b\u306e\u30d4\u30af\u30bb\u30eb\u306e\u5f37\u5ea6\u306e\u91cd\u307f\u3064\u3051\u3092\u3057\u307e\u3059\u3002<br \/>\n\u30d4\u30af\u30bb\u30eb\u304c\u305d\u306e\u30af\u30e9\u30b9\u306b\u304a\u3051\u308b\u9ad8\u3044\u5f37\u5ea6\u3092\u6301\u3063\u305f\u30a8\u30d3\u30c7\u30f3\u30b9\u3092\u6301\u3063\u3066\u3044\u308b\u5834\u5408\u3001\u91cd\u307f\u306f\u8ca0\u306b\u306a\u308a\u3001\u30a8\u30d3\u30c7\u30f3\u30b9\u304cin favor\u306e\u3068\u304d\u6b63\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u306e\u30c0\u30a4\u30a2\u30b0\u30e9\u30e0\u306f\uff11\u3064\u306e\u30e2\u30c7\u30eb\u306e\u91cd\u307f\u304c\u305d\u308c\u305e\u308c\u306e\u30af\u30e9\u30b9\u3092\u5b66\u7fd2\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u8d64\u8272\u306f\u8ca0\u306e\u91cd\u307f\u3092\u8868\u3057\u3066\u3044\u3066\u3001\u9752\u8272\u306f\u6b63\u306e\u91cd\u307f\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-weights.png\" alt=\"softmax-weights\" width=\"100%\" class=\"alignnone size-full wp-image-9522\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-weights.png 1145w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-weights-300x151.png 300w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-weights-1024x514.png 1024w\" sizes=\"(max-width: 1145px) 100vw, 1145px\" \/><\/p>\n<p>\u79c1\u305f\u3061\u306f\u30d0\u30a4\u30a2\u30b9\u3068\u547c\u3070\u308c\u308b\u8ffd\u52a0\u306e\u30a8\u30d3\u30c7\u30f3\u30b9\u3092\u52a0\u3048\u307e\u3057\u305f\u3002<br \/>\n\u57fa\u672c\u7684\u306b\u3001\u3044\u304f\u3064\u304b\u306e\u4e8b\u8c61\u306f\u5165\u529b\u306e\u72ec\u7acb\u306b\u3080\u3057\u308d\u8fd1\u3044\u3068\u3044\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u30af\u30e9\u30b9i\u306e\u30a8\u30d3\u30c7\u30f3\u30b9\u306e\u7d50\u679c\u306fx\u3092\u4e0e\u3048\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/mnst1.jpg\" alt=\"evidencei=\u2211jWi, jxj+bi\" width=\"262\" height=\"64\" class=\"alignnone size-full wp-image-9532\" \/><\/p>\n<p>Wi\u306f\u91cd\u307f\u3067bi\u306f\u30af\u30e9\u30b9i\u3068j\u306e\u30d0\u30a4\u30a2\u30b9\u3067\u3001\u5165\u529b\u3057\u305f\u753b\u50cfx\u306e\u30d4\u30af\u30bb\u30eb\u306e\u7dcf\u548c\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305d\u3053\u3067\u30a8\u30d3\u30c7\u30f3\u30b9\u306e\u8a08\u7b97\u3092\u4e88\u6e2c\u3055\u308c\u305f\u78ba\u7387\u306b\u5909\u63db\u3057\u307e\u3059\u3002<br \/>\ny\u306f\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u95a2\u6570\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>y=softmax(evidence)<\/p>\n<p>\u3053\u3053\u3067\u306e\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u306f\u300c\u8d77\u52d5\u300d\u304b\u300c\u30ea\u30f3\u30af\u300d\u95a2\u6570\u3067\u3001\u51fa\u529b\u3055\u308c\u305f\u7dda\u5f62\u95a2\u6570\u3092\u5fc5\u8981\u306a\u5f62\u306b\u6574\u5f62\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30b1\u30fc\u30b9\u3067\u306f\u300110\u306e\u30b1\u30fc\u30b9\u306e\u78ba\u7387\u5206\u5e03\u3067\u3059\u3002<br \/>\n\u3042\u306a\u305f\u306f\u305d\u308c\u3092\u3001\u30a8\u30d3\u30c7\u30f3\u30b9\u306e\u8a08\u7b97\u3092\u305d\u308c\u305e\u308c\u306e\u5165\u529b\u3057\u305f\u30af\u30e9\u30b9\u306e\u78ba\u7387\u306b\u5909\u63db\u3059\u308b\u3053\u3068\u3092\u8003\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u305d\u308c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>softmax(x) = normalize(exp\u2061(x))<\/p>\n<p>\u3082\u3057\u3042\u306a\u305f\u304c\u65b9\u7a0b\u5f0f\u3092\u5c55\u958b\u3059\u308b\u306e\u3067\u3042\u308c\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>softmax(x)i = exp\u2061(xi) \/ \u2211jexp\u2061(xj)<\/p>\n<p>\u3057\u304b\u3057\u3001\u305d\u308c\u306f\u3057\u3070\u3057\u3070\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u3092\u8003\u3048\u308b\u306e\u306b\u3088\u308a\u5f79\u7acb\u3064\u7b2c\u4e00\u306e\u65b9\u6cd5\u3067\u3059\u3002<br \/>\n\u5165\u529b\u306e\u3079\u304d\u4e57\u3068\u6b63\u898f\u5316\u3067\u3059\u3002<br \/>\n\u3079\u304d\u4e57\u306f\u3001\uff11\u3064\u591a\u304f\u306e\u30a8\u30d3\u30c7\u30f3\u30b9\u306e\u30e6\u30cb\u30c3\u30c8\u304c\u3001\u3044\u304f\u3064\u304b\u306e\u4eee\u8aac\u3092\u500d\u306b\u3059\u308b\u91cd\u307f\u3092\u5897\u52a0\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u9006\u306b\u8a00\u3048\u3070\u3001\uff11\u3064\u5c11\u306a\u3044\u30a8\u30d3\u30c7\u30f3\u30b9\u306e\u30e6\u30cb\u30c3\u30c8\u306f\u3001\u305d\u306e\u524d\u306e\u91cd\u307f\u306e\u65ad\u7247\u3092\u5f97\u308b\u4eee\u8aac\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u30bc\u30ed\u307e\u305f\u306f\u30de\u30a4\u30ca\u30b9\u306e\u91cd\u307f\u3092\u6301\u3064\u4eee\u5b9a\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u306f\u3053\u308c\u3089\u306e\u91cd\u307f\u3092\u6b63\u898f\u5316\u3057\u3001\u305d\u306e\u305f\u3081\u305d\u308c\u3089\u306f\u6b63\u3057\u3044\u78ba\u7387\u5206\u5e03\u306b\u52a0\u3048\u307e\u3059\u3002<br \/>\n\uff08\u3088\u308a\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u95a2\u6570\u306e\u76f4\u611f\u3092\u5f97\u3088\u3046\u3068\u3059\u308b\u306a\u3089\u3001\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u3067\u30d3\u30b8\u30e5\u30a2\u30eb\u304c\u5145\u5b9f\u3057\u305f\u30de\u30a4\u30b1\u30eb\u30fb\u30cb\u30fc\u30eb\u30bb\u30f3\u306e\u672c\u306e<a href=\"https:\/\/neuralnetworksanddeeplearning.com\/chap3.html#softmax\">\u7ae0<\/a>\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\uff09<\/p>\n<p>\u3042\u306a\u305f\u306f\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30\u3092\u3001Xs\u304c\u591a\u3044\u3067\u3059\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u305d\u308c\u305e\u308c\u306e\u51fa\u529b\u306b\u5bfe\u3057\u3066\u3001xs\u306e\u91cd\u307f\u4ed8\u3051\u3055\u308c\u305f\u5408\u8a08\u3092\u8a08\u7b97\u3057\u3001\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u306b\u9069\u7528\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalargraph.png\" alt=\"softmax-regression-scalargraph\"  width=\"100%\" class=\"alignnone size-full wp-image-9525\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalargraph.png 2907w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalargraph-300x120.png 300w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalargraph-1024x409.png 1024w\" sizes=\"(max-width: 2907px) 100vw, 2907px\" \/><\/p>\n<p>\u3082\u3057\u65b9\u7a0b\u5f0f\u306b\u3059\u308b\u306e\u3067\u3042\u308c\u3070\u3001\u4ee5\u4e0b\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalarequation.png\" alt=\"softmax-regression-scalarequation\"  width=\"100%\" class=\"alignnone size-full wp-image-9526\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalarequation.png 2723w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalarequation-300x69.png 300w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-scalarequation-1024x234.png 1024w\" sizes=\"(max-width: 2723px) 100vw, 2723px\" \/><\/p>\n<p>\u3053\u306e\u624b\u9806\u3092\u30d9\u30af\u30c8\u30eb\u5316\u3057\u3066\u3001\u884c\u5217\u306e\u4e57\u7b97\u306b\u5909\u63db\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306f\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u80fd\u7387\u306b\u5bfe\u3057\u3066\u52b9\u679c\u7684\u3067\u3059\u3002\uff08\u305d\u308c\u306f\u8003\u3048\u65b9\u306b\u3082\u6709\u7528\u3067\u3059\uff09<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-vectorequation.png\" alt=\"softmax-regression-vectorequation\"  width=\"100%\" class=\"alignnone size-full wp-image-9527\" srcset=\"https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-vectorequation.png 2624w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-vectorequation-300x73.png 300w, https:\/\/www.itblog.jp\/wp-content\/uploads\/2016\/06\/softmax-regression-vectorequation-1024x250.png 1024w\" sizes=\"(max-width: 2624px) 100vw, 2624px\" \/><\/p>\n<p>\u3088\u308a\u30b3\u30f3\u30d1\u30af\u30c8\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5358\u7d14\u306b\u66f8\u304f\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>y = softmax(Wx + b)<\/p>\n<h2>\u56de\u5e30\u306e\u5b9f\u88c5<\/h2>\n<p>Python\u3067\u306e\u52b9\u7387\u7684\u306a\u6570\u5024\u8a08\u7b97\u3092\u3059\u308b\u306b\u306f\u3001\u4e00\u822c\u7684\u306bPython\u5916\u306e\u884c\u5217\u306e\u4e57\u7b97\u306e\u3088\u3046\u306a\u91cd\u3044\u51e6\u7406\u306e\u6f14\u7b97\u3092\u3059\u308bNumPy\u306e\u3088\u3046\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u3092\u4f7f\u3044\u3001\u4ed6\u306e\u8a00\u8a9e\u306b\u5b9f\u88c5\u3055\u308c\u305f\u52b9\u7387\u306e\u3088\u3044\u30b3\u30fc\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u6b8b\u5ff5\u306a\u304c\u3089\u3001Python\u306e\u5168\u3066\u306e\u6f14\u7b97\u306b\u5207\u308a\u66ff\u3048\u308b\u306e\u306b\u591a\u304f\u306e\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9\u306f\u3001\u3082\u3057GPU\u3067\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u304b\u3001\u5206\u6563\u5f62\u5f0f\u306e\u5834\u5408\u306b\u3068\u308a\u308f\u3051\u60aa\u304f\u3001\u30c7\u30fc\u30bf\u8ee2\u9001\u306b\u9ad8\u3044\u30b3\u30b9\u30c8\u304c\u304b\u304b\u308a\u307e\u3059\u3002<br \/>\nTensorFlow\u3082\u307e\u305fpython\u306e\u5916\u306b\u91cd\u304f\u3042\u308a\u307e\u3059\u304c\u3001\u3057\u304b\u3057\u30b9\u30c6\u30c3\u30d7\u3092\u8e0f\u3080\u3053\u3068\u3067\u3053\u306e\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9\u3092\u907f\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\nPython\u304b\u3089\u72ec\u7acb\u3057\u305f\u5358\u4e00\u306e\u91cd\u3044\u6f14\u7b97\u306e\u4ee3\u308f\u308a\u306b\u3001TensorFlow\u306f\u5b8c\u5168\u306bPython\u306e\u5916\u306e\u76f8\u4e92\u306e\u6f14\u7b97\u306e\u30b0\u30e9\u30d5\u3092\u63cf\u304f\u3053\u3068\u3092\u53ef\u80fd\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\uff08\u3053\u306e\u3088\u3046\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u306f\u3001\u5c11\u306a\u3044\u6a5f\u68b0\u5b66\u7fd2\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u306b\u898b\u3089\u308c\u307e\u3059\uff09<\/p>\n<p>TensorFlow\u3092\u4f7f\u3046\u306b\u306f\u3001\u305d\u308c\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>import tensorflow as tf<\/p>\n<p>\u3053\u308c\u3089\u306e\u76f8\u4e92\u6f14\u7b97\u3092\u3001\u8a18\u53f7\u5909\u6570\u3092\u51e6\u7406\u3059\u308b\u3053\u3068\u3067\u63cf\u304d\u307e\u3059\u30021\u3064\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>x = tf.placeholder(tf.float32, [None, 784])<\/p>\n<p>x\u306f\u4e00\u5b9a\u306e\u5024\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u305d\u308c\u306f\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u3067\u3001\u305d\u306e\u5024\u306f\u8a08\u7b97\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306eTensorFlow\u3078\u306e\u554f\u3044\u5408\u308f\u305b\u306e\u969b\u306b\u5165\u529b\u3057\u307e\u3059\u3002<br \/>\n\u79c1\u9054\u306f\u3001\u3044\u304f\u3064\u3082\u306e\u5165\u529b\u3057\u305fMNIST\u306e\u753b\u50cf\u3092\u3001\u305d\u308c\u305e\u308c784\u6b21\u5143\u306e\u30d9\u30af\u30c8\u30eb\u306b\u5e73\u5766\u5316\u3057\u305f\u3044\u3067\u3059\u3002<br \/>\n\u79c1\u9054\u306f\u3053\u308c\u3092\u3001[Noneg,784]\u306e\u578b\u306e2D\u306e\u6d6e\u52d5\u5c0f\u6570\u306e\u30c6\u30f3\u30bd\u30eb\u3068\u3057\u3066\u8868\u3057\u307e\u3059\u3002<br \/>\n\uff08\u6b21\u5143\u306f\u4f55\u306e\u9577\u3055\u306b\u3082\u306a\u308a\u3046\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u306f\u3042\u308a\u307e\u305b\u3093\uff09<\/p>\n<p>\u79c1\u9054\u3082\u307e\u305f\u3001\u30e2\u30c7\u30eb\u91cd\u307f\u3068\u30d0\u30a4\u30a2\u30b9\u3092\u5fc5\u8981\u3068\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u79c1\u9054\u306f\u3053\u308c\u3089\u3092\u8ffd\u52a0\u306e\u5165\u529b\u306e\u3088\u3046\u306b\u6271\u3046\u3053\u3068\u3092\u60f3\u50cf\u3067\u304d\u307e\u3059\u304c\u3001TensorFlow\u306f\u3053\u308c\u3089\u3067\u3055\u3048\u3082\u3088\u308a\u3088\u304f\u6271\u3046\u65b9\u6cd5\u3067\u3059\uff1a\u5909\u6570A\u306f\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306a\u6f14\u7b97\u306eTensorFlow\u306e\u30b0\u30e9\u30d5\u306b\u5b58\u5728\u3059\u308b\u5909\u66f4\u53ef\u80fd\u306a\u30c6\u30f3\u30bd\u30eb\u3067\u3059\u3002<br \/>\n\u305d\u308c\u306f\u4f7f\u7528\u53ef\u80fd\u3067\u8a08\u7b97\u306b\u3088\u3063\u3066\u4fee\u6b63\u3055\u308c\u307e\u3057\u305f\u3002<br \/>\n\u6a5f\u68b0\u5b66\u7fd2\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u304a\u3044\u3066\u306f\u3001\u4e00\u822c\u7684\u306b\u5909\u6570\u306b\u3088\u3063\u3066\u30e2\u30c7\u30eb\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u6301\u3061\u307e\u3059\u3002<\/p>\n<p>W = tf.Variable(tf.zeros([784, 10]))<br \/>\nb = tf.Variable(tf.zeros([10]))<\/p>\n<p>\u79c1\u9054\u306f\u3001\u5909\u6570\u306e\u521d\u671f\u5024\u306etf.Variable\u306b\u4e0e\u3048\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3053\u308c\u3089\u306e\u5909\u6570\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30b1\u30fc\u30b9\u3067\u306f\u3001W\u3068b\u306e\u4e21\u65b9\u3092\u30bc\u30ed\u3067\u6e80\u305f\u3057\u305f\u30c6\u30f3\u30bd\u30eb\u306e\u3088\u3046\u306b\u521d\u671f\u5316\u3057\u307e\u3059\u3002<br \/>\nW\u3068\uff42\u306b\u3064\u3044\u3066\u5b66\u3076\u3068\u3001\u305d\u308c\u3089\u306e\u521d\u671f\u5024\u304c\u4f55\u3067\u3042\u308b\u304b\u304c\u305d\u308c\u307b\u3069\u554f\u984c\u306b\u306a\u3089\u306a\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>W\u306f[784,10]\u306e\u578b\u3067\u3059\u306a\u305c\u306a\u3089\u305d\u308c\u306e784\u6b21\u5143\u753b\u50cf\u306e\u30d9\u30af\u30c8\u30eb\u3092\u3001\u7570\u306a\u308b\u30af\u30e9\u30b910\u6b21\u5143\u306e\u30d9\u30af\u30c8\u30eb\u639b\u3051\u305f\u3044\u3067\u3059\u3002<br \/>\nb\u306f[10]\u306e\u578b\u3092\u6301\u3063\u3066\u3044\u3066\u3001\u51fa\u529b\u306b\u52a0\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u307e\u3067\u304d\u3066\u3001\u30e2\u30c7\u30eb\u3092\u6e80\u305f\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305d\u308c\u306f\uff11\u3064\u306e\u30e9\u30a4\u30f3\u3092\u8981\u3057\u307e\u3059\u3002<\/p>\n<p>y = tf.nn.softmax(tf.matmul(x, W) + b)<\/p>\n<p>\u6700\u521d\u306b\u3001x\u3068W\u306e\u4e57\u7b97\u3092tf.matmul(x, W)\u3068\u8868\u73fe\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306f\u65b9\u7a0b\u5f0f\u306b\u304a\u3044\u3066\u305d\u308c\u3089\u3092\u639b\u3051\u308b\u3053\u3068\u3067\u53cd\u8ee2\u3055\u308c\u3001\u305d\u3053\u3067\u8907\u6570\u306e\u5165\u529b\u306e2D\u30c6\u30f3\u30bd\u30eb\u306ex\u306e\u3088\u3046\u306b\u6271\u3046\u5c0f\u3055\u306a\u30b3\u30c4\u306e\u3088\u3046\u306aWx\u3092\u6301\u3061\u307e\u3059\u3002<br \/>\n\u79c1\u9054\u306f\u305d\u3053\u3067b\u3092\u52a0\u3048\u3001\u305d\u3057\u3066\u6700\u7d42\u7684\u306btf.nn.softmax\u3092\u9069\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u304a\u3057\u307e\u3044\u3067\u3059\u3002<br \/>\n\u305d\u308c\u306f\u305f\u3060\u79c1\u9054\u306b\u3001\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306e\u77ed\u3044\u7dda\u306e\u7d44\u306e\u5f8c\u306b\u30e2\u30c7\u30eb\u3092\u5b9a\u7fa9\u3059\u308b\u305f\u3081\u306e\uff11\u3064\u306e\u7dda\u3092\u53d6\u308a\u307e\u3059\u3002<br \/>\n\u305d\u308c\u306fTensorFlow\u304c\u30bd\u30d5\u30c8\u30de\u30c3\u30af\u30b9\u56de\u5e30\u3092\u3068\u308a\u308f\u3051\u7c21\u5358\u306b\u3059\u308b\u305f\u3081\u3044\u30c7\u30b6\u30a4\u30f3\u3055\u308c\u3066\u3044\u308b\u304b\u3089\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u305d\u308c\u306f\u5358\u306b\u6a5f\u68b0\u5b66\u7fd2\u306e\u30e2\u30c7\u30eb\u304b\u3089\u7269\u7406\u30b7\u30e5\u30df\u30ec\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u5e7e\u901a\u308a\u306e\u6570\u5024\u8a08\u7b97\u3092\u63cf\u304f\u305f\u3081\u306e\u67d4\u8edf\u306a\u65b9\u6cd5\u3067\u3059\u3002<br \/>\n\u305d\u3057\u3066\u3044\u3063\u305f\u3093\u5b9a\u7fa9\u3055\u308c\u308c\u3070\u3001\u30e2\u30c7\u30eb\u306f\u7570\u306a\u308b\u30c7\u30d0\u30a4\u30b9\u3067\u52d5\u4f5c\u3067\u304d\u307e\u3059\u3002\uff08\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u306eCPU\u3084GPU\u3001\u305d\u3057\u3066\u643a\u5e2f\u96fb\u8a71\u3059\u3089\uff09<\/p>\n<h2>\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0<\/h2>\n<p>\u30e2\u30c7\u30eb\u3092\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u305f\u3081\u306b\u3001\u79c1\u9054\u306f\u826f\u3044\u30e2\u30c7\u30eb\u3068\u306f\u4f55\u3092\u610f\u5473\u3057\u3066\u3044\u308b\u304b\u306e\u5b9a\u7fa9\u3092\u5fc5\u8981\u3068\u3057\u307e\u3059\u3002<br \/>\n\u5b9f\u969b\u306b\u306f\u3001\u6a5f\u68b0\u5b66\u7fd2\u306b\u304a\u3044\u3066\u79c1\u9054\u306f\u4e00\u822c\u7684\u306b\u3001\u30b3\u30b9\u30c8\u307e\u305f\u306f\u640d\u5931\u3092\u547c\u3076\u306e\u306e\u3092\u60aa\u3044\u30e2\u30c7\u30eb\u3068\u5b9a\u7fa9\u3057\u3001\u305d\u3057\u3066\u3069\u3046\u60aa\u3044\u306e\u304b\u306e\u6700\u5c0f\u5316\u3092\u8a66\u307f\u307e\u3059\u3002\u3057\u304b\u3057\u305d\u306e\uff12\u3064\u306f\u540c\u3058\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u3068\u3066\u3082\u5171\u901a\u3068\u3057\u3066\u3001\u3068\u3066\u3082\u3088\u3044\u30b3\u30b9\u30c8\u95a2\u6570\u306f\u300c\u30af\u30ed\u30b9\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u300d\u3067\u3059\u3002<br \/>\n\u9a5a\u3044\u305f\u3053\u3068\u306b\u3001\u30af\u30ed\u30b9\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u306f\u60c5\u5831\u30ea\u30aa\u30f3\u306b\u304a\u3051\u308b\u60c5\u5831\u5727\u7e2e\u30b3\u30fc\u30c9\u306b\u3064\u3044\u3066\u8003\u3048\u308b\u3053\u3068\u304b\u3089\u751f\u3058\u307e\u3059\u304c\u3001\u3057\u304b\u3057\u306a\u304c\u3089\u305d\u308c\u306f\u591a\u304f\u306e\u30a8\u30ea\u30a2\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u30a2\u30a4\u30c7\u30a2\u3092\u6a5f\u68b0\u5b66\u7fd2\u3078\u306e\u30ae\u30e3\u30f3\u30d6\u30eb\u306b\u5f15\u304d\u4e0a\u3052\u307e\u3059\u3002<br \/>\n\u305d\u308c\u306f\u5b9a\u7fa9\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>Hy\u2032(y)=\u2212\u2211iyi\u2032log\u2061(yi)<\/p>\n<p>y\u306f\u4e88\u6e2c\u3055\u308c\u305f\u78ba\u7387\u5206\u5e03\u3067\u3042\u308a\u3001y&#8217;\u306f\u771f\u306e\u5206\u5e03\uff08\u5165\u529b\u3059\u308b\u3067\u3042\u308d\u3046\u3072\u3068\u3064\u306e\u71b1\u3044\u30d9\u30af\u30c8\u30eb\uff09\u3067\u3059\u3002<br \/>\n\u3044\u304f\u3064\u306e\u5927\u96d1\u628a\u306a\u5224\u65ad\u3067\u306f\u3001\u30af\u30ed\u30b9\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u306f\u3069\u308c\u3060\u3051\u771f\u3092\u63cf\u304f\u305f\u3081\u306e\u4e88\u6e2c\u306b\u7121\u99c4\u304c\u591a\u3044\u304b\u3092\u8a08\u6e2c\u3057\u307e\u3059\u3002<br \/>\n\u30af\u30ed\u30b9\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u306e\u3088\u308a\u591a\u304f\u306e\u8a73\u7d30\u306f\u3001\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u7bc4\u56f2\u3092\u8d85\u3048\u3066\u3044\u307e\u3059\u304c\u3001\u3057\u304b\u3057\u305d\u308c\u306f<a href=\"https:\/\/colah.github.io\/posts\/2015-09-Visual-Information\/\">\u7406\u89e3\u3059\u308b<\/a>\u4fa1\u5024\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30af\u30ed\u30b9\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u3092\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306b\u6700\u521d\u306b\u65b0\u3057\u3044\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u30fc\u3092\u6b63\u3057\u3044\u89e3\u306b\u5165\u529b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>y_ = tf.placeholder(tf.float32, [None, 10])<\/p>\n<p>\u305d\u3053\u3067\u79c1\u9054\u306f\u30af\u30ed\u30b9\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u2212\u2211y\u2032log\u2061(y)\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))<\/p>\n<p>\u6700\u521d\u306b\u3001tf.log\u306f\u305d\u308c\u305e\u308c\u306e\u8981\u7d20\u306e\u5bfe\u6570\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002\u6b21\u306b\u3001tf.log(y)\u306e\u8981\u7d20\u306e_y\u306e\u8981\u7d20\u3092\u4e57\u7b97\u3057\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066tf.reduce_sum\u306freduction_indices=[1]\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u305f\u3081\u3001y\u306e2\u3064\u76ee\u306e\u6b21\u5143\u306e\u4e2d\u306e\u8981\u7d20\u306b\u52a0\u3048\u307e\u3059\u3002<br \/>\n\u6700\u7d42\u7684\u306b\u3001tf.reduce_mean\u306f\u30d0\u30c3\u30c1\u306e\u4e2d\u306e\u3059\u3079\u3066\u306e\u4f8b\u306e\u4e2d\u592e\u5024\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u306f\u79c1\u9054\u306f\u3001\u30e2\u30c7\u30eb\u304c\u4f55\u3092\u3059\u308b\u3079\u304d\u304b\u3092\u77e5\u308a\u3001\u305d\u308c\u306f\u3001\u8a13\u7df4\u3057\u305fTensorFlow\u3092\u6301\u3064\u306e\u306b\u3068\u3066\u3082\u7c21\u5358\u3067\u3059\u3002<br \/>\n\u306a\u305c\u306a\u3089TensorFlow\u306f\u8a08\u7b97\u306e\u30b0\u30e9\u30d5\u5168\u4f53\u3092\u77e5\u308a\u3001\u305d\u308c\u306f\u81ea\u52d5\u7684\u306b<a href=\"https:\/\/colah.github.io\/posts\/2015-08-Backprop\/\">\u30d0\u30c3\u30af\u30d7\u30ed\u30d1\u30b2\u30fc\u30b7\u30e7\u30f3\u30a2\u30eb\u30b4\u30ea\u30b9\u30e0\uff08\u8aa4\u5dee\u9006\u4f1d\u642c\u6cd5\uff09<\/a>\u3092\u3001\u3069\u3046\u5909\u6570\u304c\u6700\u5c0f\u5316\u306e\u30b3\u30b9\u30c8\u306b\u5f71\u97ff\u3059\u308b\u304b\u3092\u52b9\u7387\u7684\u306b\u6c7a\u5b9a\u3059\u308b\u305f\u3081\u306b\u81ea\u52d5\u7684\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u305d\u3053\u3067\u9078\u629e\u3057\u305f\u6700\u9069\u5316\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u3001\u5909\u6570\u3092\u5909\u66f4\u3057\u3066\u30b3\u30b9\u30c8\u3092\u4e0b\u3052\u308b\u305f\u3081\u306b\u9069\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)<\/p>\n<p>\u3053\u306e\u30b1\u30fc\u30b9\u3067\u306f\u3001\u79c1\u9054\u306fTensorFlow\u306b\u5c0b\u306d\u307e\u3059 50%\u306e\u50be\u659c\u306e\u52fe\u914d\u964d\u4e0b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u4f7f\u3063\u3066\u30af\u30ed\u30b9\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u3092\u6700\u5c0f\u5316\u3059\u308b\u3053\u3068\u306f\u5358\u7d14\u306a\u624b\u9806\u3067\u3001\u305d\u3053\u3067TensorFlow\u306f\u5358\u7d14\u306b\u305d\u308c\u305e\u308c\u306e\u5909\u6570\u3092\u5c11\u3057\u306e\u30d3\u30c3\u30c8\u3092\u305d\u306e\u30b3\u30b9\u30c8\u3092\u6e1b\u5c11\u3059\u308b\u65b9\u5411\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<br \/>\n\u3057\u304b\u3057TensorFlow\u3082\u307e\u305f<a href=\"https:\/\/www.tensorflow.org\/versions\/r0.9\/api_docs\/python\/train.html#optimizers\">\u591a\u304f\u306e\u6700\u9069\u5316\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0<\/a>\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002(\uff11\u3064\u306f\u30e9\u30a4\u30f3\u3092\u8abf\u6574\u3059\u308b\u3060\u3051\u306e\u3053\u3068\u3067\u3059\u3002)<\/p>\n<p>TensowFlow\u304c\u5b9f\u969b\u3053\u3053\u3067\u4f55\u3092\u3059\u308b\u304b\u306f\u3001\u5834\u5408\u306b\u3088\u308a\u3001\u65b0\u3057\u3044\u64cd\u4f5c\u3092\u30d0\u30c3\u30af\u30d7\u30ed\u30d1\u30b2\u30fc\u30b7\u30e7\u30f3\uff08\u8aa4\u5dee\u9006\u4f1d\u64ad\u6cd5\uff09\u3068\u52fe\u914d\u964d\u4e0b\u3092\u5b9f\u88c5\u3059\u308b\u30b0\u30e9\u30d5\u306b\u52a0\u3048\u307e\u3059\u3002<br \/>\n\u305d\u3053\u3067\u305d\u308c\u306f\u5358\u4e00\u306e\u64cd\u4f5c\u3092\u5909\u63db\u3057\u3001\u5b9f\u884c\u3057\u305f\u3068\u304d\u3001\u52fe\u914d\u964d\u4e0b\u306e\u8a13\u7df4\u306e\u30b9\u30c6\u30c3\u30d7\u3092\u3057\u3001\u5909\u6570\u3092\u30b3\u30b9\u30c8\u3092\u4e0b\u3052\u308b\u305f\u3081\u306b\u5fae\u8abf\u6574\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u30e2\u30c7\u30eb\u3092\u8a13\u7df4\u3059\u308b\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u6700\u5f8c\u306b\u306f\u3058\u3081\u308b\u524d\u306b\u3001\u4f5c\u6210\u3057\u305f\u5909\u6570\u3092\u521d\u671f\u5316\u3059\u308b\u64cd\u4f5c\u3092\u52a0\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>init = tf.initialize_all_variables()<\/p>\n<p>\u3053\u308c\u3067\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u3067\u30e2\u30c7\u30eb\u3092\u958b\u59cb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u305d\u3057\u3066\u5909\u6570\u3092\u521d\u671f\u5316\u3059\u308b\u64cd\u4f5c\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>sess = tf.Session()<br \/>\nsess.run(init)<\/p>\n<p>\u3055\u3042\u3001\u8a13\u7df4\u3057\u307e\u3057\u3087\u3046\u30021000\u56de\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u306e\u30b9\u30c6\u30c3\u30d7\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>for i in range(1000):<br \/>\n  batch_xs, batch_ys = mnist.train.next_batch(100)<br \/>\n  sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})<\/p>\n<p>\u305d\u308c\u305e\u308c\u306e\u30eb\u30fc\u30d7\u306b\u304a\u3051\u308b\u30b9\u30c6\u30c3\u30d7\u3067\u3001\u8a13\u7df4\u306e\u30bb\u30c3\u30c8\u304b\u3089100\u306e\u30e9\u30f3\u30c0\u30e0\u306a\u30c7\u30fc\u30bf\u306e\u30d0\u30c3\u30c1\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u30fc\u3092\u7f6e\u304d\u63db\u3048\u308b\u305f\u3081\u306b\u30d0\u30c3\u30c1\u30c7\u30fc\u30bf\u306e\u8a13\u7df4\u306e\u30b9\u30c6\u30c3\u30d7\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u5c0f\u3055\u306a\u30e9\u30f3\u30c0\u30e0\u306e\u30c7\u30fc\u30bf\u306e\u30d0\u30c3\u30c1\u3092\u4f7f\u3046\u3053\u3068\u3092\u3001\u78ba\u7387\u8ad6\u7684\u306a\u8a13\u7df4\u3068\u547c\u3070\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n&#8211;\u3053\u306e\u30b1\u30fc\u30b9\u3067\u306f\u3001\u78ba\u7387\u8ad6\u7684\u52fe\u914d\u964d\u4e0b\u3067\u3059\u3002<br \/>\n\u7406\u60f3\u7684\u306b\u306f\u3001\u3059\u3079\u3066\u306e\u8a13\u7df4\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u3059\u3079\u3066\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u3044\u305f\u3044\u3001\u306a\u305c\u306a\u3089\u4f55\u3092\u3059\u308b\u3079\u304d\u304b\u306e\u3088\u308a\u3088\u3044\u30bb\u30f3\u30b9\u3092\u63d0\u4f9b\u3057\u3066\u304f\u308c\u308b\u304b\u3089\u3067\u3001\u3057\u304b\u3057\u305d\u308c\u306f\u9ad8\u4fa1\u3067\u3059\u3002<br \/>\n\u305d\u3053\u3067\u4ee3\u308f\u308a\u306b\u3001\u7570\u306a\u308b\u90e8\u5206\u96c6\u5408\u3092\u3044\u3064\u3082\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3092\u884c\u3046\u306e\u306f\u5b89\u304f\u3066\u540c\u69d8\u306e\u5229\u76ca\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30e2\u30c7\u30eb\u3092\u8a55\u4fa1\u3059\u308b<\/h2>\n<p>\u30e2\u30c7\u30eb\u306f\u3069\u3046\u3059\u308b\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>\u3044\u3044\u3067\u3057\u3087\u3046\u3001\u6700\u521d\u306b\u3001\u3069\u3053\u3067\u6b63\u3057\u3044\u30e9\u30d9\u30eb\u3092\u4e88\u6e2c\u3059\u308b\u304b\u3092\u89e3\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\ntf.argmax\u306f\u6975\u5ea6\u306b\u4f7f\u3044\u3084\u3059\u3044\u95a2\u6570\u3067\u3001\u305d\u308c\u306f\u3044\u304f\u3064\u304b\u306e\u8ef8\u306e\u30c6\u30f3\u30bd\u30eb\u306e\u9ad8\u3044\u30a8\u30f3\u30c8\u30ea\u30fc\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4e0e\u3048\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001tf.argmax(y,1)\u306f\u30e2\u30c7\u30eb\u306e\u30e9\u30d9\u30eb\u3067\u3001\u305d\u308c\u305e\u308c\u306e\u5165\u529b\u306b\u6700\u3082\u8fd1\u304f\u3001tf.argmax(y_,1)\u3000\u304c\u6b63\u3057\u3044\u30e9\u30d9\u30eb\u3067\u3059\u3002<br \/>\n\u79c1\u9054\u306ftf.equal\u3092\u3001\u4e88\u6e2c\u304c\u771f\u3068\u30de\u30c3\u30c1\u3059\u308b\u5834\u5408\u306b\u30c1\u30a7\u30c3\u30af\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))<\/p>\n<p>\u3053\u308c\u306f\u30d6\u30fc\u30eb\u6570\u306e\u30ea\u30b9\u30c8\u3092\u4e0e\u3048\u307e\u3059\u3002<br \/>\n\u4f55\u306e\u90e8\u5206\u304c\u6b63\u3057\u3044\u304b\u3092\u7279\u5b9a\u3059\u308b\u305f\u3081\u3001\u6d6e\u52d5\u5c0f\u6570\u3092\u30ad\u30e3\u30b9\u30c8\u3057\u3001\u4e2d\u592e\u5024\u3092\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001[True, False, True, True]\u306f[1,0,1,1] \u306b\u306a\u308a\u30010,75\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))<\/p>\n<p>\u6700\u7d42\u7684\u306b\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u6b63\u78ba\u3055\u3092\u554f\u3044\u5408\u308f\u305b\u307e\u3059\u3002<\/p>\n<p>print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))<\/p>\n<p>\u3053\u308c\u306f\u304a\u3088\u305d92%\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\n\u3044\u3084\u3001\u305d\u3046\u3067\u3082\u306a\u3044\u3067\u3059\u3088\u3002<br \/>\n\u5b9f\u969b\u306b\u3001\u305d\u308c\u306f\u3068\u3066\u3082\u60aa\u3044\u3067\u3059\u3002<br \/>\n\u3053\u308c\u306f\u3068\u3066\u3082\u7c21\u5358\u306a\u30e2\u30c7\u30eb\u3092\u4f7f\u3046\u304b\u3089\u3067\u3059\u3002<br \/>\n\u5c0f\u3055\u306a\u5909\u66f4\u3092\u4f34\u3046\u3068\u304d\u300197%\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u3044\u307e\u3059\u3002<br \/>\n\u6700\u9ad8\u306e\u30e2\u30c7\u30eb\u3067\u3042\u308c\u307099.7%\u306e\u6b63\u78ba\u3055\u3092\u8d85\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff01\uff08\u3088\u308a\u591a\u304f\u306e\u60c5\u5831\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/rodrigob.github.io\/are_we_there_yet\/build\/classification_datasets_results.html\">\u7d50\u679c\u8868<\/a>\u3092\u898b\u3066\u4e0b\u3055\u3044\u3002\uff09<\/p>\n<p>\u3053\u306e\u30e2\u30c7\u30eb\u304b\u3089\u5b66\u3076\u3053\u3068\u306e\u4f55\u304c\u554f\u984c\u3067\u3057\u3087\u3046\u3002<br \/>\n\u307e\u3060\u3001\u3053\u308c\u3089\u306e\u7d50\u679c\u306b\u3064\u3044\u3066\u5c11\u3057\u304c\u3063\u304b\u308a\u3059\u308b\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3042\u308c\u3070\u3001\u3088\u308a\u826f\u304f\u3057\u305f<a href=\"https:\/\/www.tensorflow.org\/versions\/r0.9\/tutorials\/mnist\/pros\/index.html\">\u6b21\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/a>\u3092\u8abf\u3079\u3066\u307f\u3066\u3001\u3069\u3046\u3084\u3063\u3066\u3088\u308a\u6d17\u7df4\u3055\u308c\u305fTensorFlow\u3092\u4f7f\u3063\u305f\u30e2\u30c7\u30eb\u3092\u69cb\u7bc9\u3059\u308b\u304b\u3092\u5b66\u3093\u3067\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tensorflow\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3068\u3082\u3044\u3048\u308b\u300cMNIST For ML Beginners\u300d\u306e\u82f1\u6587\u306b\u3064\u3044\u3066\u3001\u6a5f\u68b0\u5b66\u7fd2\u521d\u5fc3\u8005\u3068\u3044\u3046\u3053\u3068\u3067\u307e\u305a\u6587\u7ae0\u3092\u548c\u8a33\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u516c\u5f0f\u30b5\u30a4\u30c8\uff08\u82f1\u8a9e\uff09\u306f\u3053\u3061\u3089 \u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306f\u3001\u6a5f\u68b0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114],"tags":[],"class_list":["post-9517","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9517"}],"version-history":[{"count":1,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9517\/revisions"}],"predecessor-version":[{"id":9529,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9517\/revisions\/9529"}],"wp:attachment":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}