{"id":193533,"date":"2024-11-12T22:58:22","date_gmt":"2024-11-12T14:58:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/193533\/"},"modified":"2024-11-12T22:58:23","modified_gmt":"2024-11-12T14:58:23","slug":"%e5%ad%b8%e7%bf%92%e6%a9%9f%e5%99%a8%e5%ad%b8%e7%bf%92%ef%bc%9a%e6%8e%a2%e7%b4%a2mnist%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%87%89%e7%94%a8-mnist%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e4%bd%bf","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/193533\/","title":{"rendered":"\u5b78\u7fd2\u6a5f\u5668\u5b78\u7fd2\uff1a\u63a2\u7d22mnist\u6578\u64da\u5eab\u7684\u61c9\u7528 (mnist\u6578\u64da\u5eab\u7684\u4f7f\u7528)"},"content":{"rendered":"<h1 id=\"%e5%ad%b8%e7%bf%92%e6%a9%9f%e5%99%a8%e5%ad%b8%e7%bf%92%ef%bc%9a%e6%8e%a2%e7%b4%a2mnist%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%87%89%e7%94%a8-QXYzyVvwxj\">\u5b78\u7fd2\u6a5f\u5668\u5b78\u7fd2\uff1a\u63a2\u7d22MNIST\u6578\u64da\u5eab\u7684\u61c9\u7528<\/h1>\n<p>\u96a8\u8457\u4eba\u5de5\u667a\u80fd\u6280\u8853\u7684\u8fc5\u901f\u767c\u5c55\uff0c\u6a5f\u5668\u5b78\u7fd2\u5df2\u6210\u70ba\u4e00\u500b\u71b1\u9580\u7684\u7814\u7a76\u9818\u57df\u3002\u5c0d\u65bc\u521d\u5b78\u8005\u4f86\u8aaa\uff0cMNIST\u6578\u64da\u5eab\u662f\u4e00\u500b\u7406\u60f3\u7684\u8d77\u9ede\u3002MNIST\uff08Modified National Institute of Standards and Technology\uff09\u6578\u64da\u5eab\u662f\u4e00\u500b\u5305\u542b\u624b\u5beb\u6578\u5b57\u7684\u6578\u64da\u96c6\uff0c\u5ee3\u6cdb\u7528\u65bc\u8a13\u7df4\u5404\u7a2e\u5716\u50cf\u8655\u7406\u7cfb\u7d71\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eMNIST\u6578\u64da\u5eab\u7684\u7279\u9ede\u3001\u61c9\u7528\u53ca\u5176\u5728\u6a5f\u5668\u5b78\u7fd2\u4e2d\u7684\u91cd\u8981\u6027\u3002<\/p>\n<h2 id=\"mnist%e6%95%b8%e6%93%9a%e5%ba%ab%e6%a6%82%e8%bf%b0-QXYzyVvwxj\">MNIST\u6578\u64da\u5eab\u6982\u8ff0<\/h2>\n<p>MNIST\u6578\u64da\u5eab\u753160,000\u500b\u8a13\u7df4\u6a23\u672c\u548c10,000\u500b\u6e2c\u8a66\u6a23\u672c\u7d44\u6210\uff0c\u6bcf\u500b\u6a23\u672c\u90fd\u662f28&#215;28\u50cf\u7d20\u7684\u7070\u5ea6\u5716\u50cf\uff0c\u8868\u793a0\u52309\u7684\u624b\u5beb\u6578\u5b57\u3002\u9019\u4e9b\u5716\u50cf\u7d93\u904e\u6a19\u6e96\u5316\u8655\u7406\uff0c\u4e26\u4e14\u6bcf\u500b\u5716\u50cf\u90fd\u9644\u6709\u76f8\u61c9\u7684\u6a19\u7c64\uff0c\u9019\u4f7f\u5f97\u5b83\u6210\u70ba\u4e00\u500b\u975e\u5e38\u9069\u5408\u7528\u65bc\u76e3\u7763\u5b78\u7fd2\u7684\u6578\u64da\u96c6\u3002<\/p>\n<h3 id=\"%e6%95%b8%e6%93%9a%e9%9b%86%e7%9a%84%e7%b5%90%e6%a7%8b-QXYzyVvwxj\">\u6578\u64da\u96c6\u7684\u7d50\u69cb<\/h3>\n<ul>\n<li><strong>\u8a13\u7df4\u96c6\uff1a<\/strong>60,000\u500b\u6a23\u672c\uff0c\u7528\u65bc\u6a21\u578b\u7684\u8a13\u7df4\u3002<\/li>\n<li><strong>\u6e2c\u8a66\u96c6\uff1a<\/strong>10,000\u500b\u6a23\u672c\uff0c\u7528\u65bc\u8a55\u4f30\u6a21\u578b\u7684\u6027\u80fd\u3002<\/li>\n<li><strong>\u5716\u50cf\u683c\u5f0f\uff1a<\/strong>\u6bcf\u500b\u5716\u50cf\u70ba28&#215;28\u50cf\u7d20\u7684\u7070\u5ea6\u5716\u3002<\/li>\n<li><strong>\u6a19\u7c64\uff1a<\/strong>\u6bcf\u500b\u5716\u50cf\u5c0d\u61c9\u7684\u6578\u5b57\uff080-9\uff09\u3002<\/li>\n<\/ul>\n<h2 id=\"mnist%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%87%89%e7%94%a8-QXYzyVvwxj\">MNIST\u6578\u64da\u5eab\u7684\u61c9\u7528<\/h2>\n<p>MNIST\u6578\u64da\u5eab\u7684\u4e3b\u8981\u61c9\u7528\u5728\u65bc\u624b\u5beb\u6578\u5b57\u8b58\u5225\uff0c\u4f46\u5b83\u7684\u5f71\u97ff\u9060\u4e0d\u6b62\u65bc\u6b64\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5177\u9ad4\u7684\u61c9\u7528\u5834\u666f\uff1a<\/p>\n<h3 id=\"1-%e6%a8%a1%e5%9e%8b%e8%a8%93%e7%b7%b4%e8%88%87%e6%b8%ac%e8%a9%a6-QXYzyVvwxj\">1. \u6a21\u578b\u8a13\u7df4\u8207\u6e2c\u8a66<\/h3>\n<p>\u7531\u65bcMNIST\u6578\u64da\u96c6\u7684\u7c21\u55ae\u6027\u548c\u6a19\u6e96\u5316\uff0c\u8a31\u591a\u6a5f\u5668\u5b78\u7fd2\u7b97\u6cd5\u90fd\u53ef\u4ee5\u5728\u6b64\u6578\u64da\u96c6\u4e0a\u9032\u884c\u8a13\u7df4\u548c\u6e2c\u8a66\u3002\u5e38\u898b\u7684\u7b97\u6cd5\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u652f\u6301\u5411\u91cf\u6a5f\uff08SVM\uff09\uff1a<\/strong>\u901a\u904e\u5c07\u6578\u64da\u6620\u5c04\u5230\u9ad8\u7dad\u7a7a\u9593\u4f86\u9032\u884c\u5206\u985e\u3002<\/li>\n<li><strong>\u5377\u7a4d\u795e\u7d93\u7db2\u7d61\uff08CNN\uff09\uff1a<\/strong>\u5c08\u9580\u7528\u65bc\u8655\u7406\u5716\u50cf\u6578\u64da\u7684\u6df1\u5ea6\u5b78\u7fd2\u6a21\u578b\u3002<\/li>\n<li><strong>\u6c7a\u7b56\u6a39\uff1a <\/strong>\u901a\u904e\u6a39\u72c0\u7d50\u69cb\u9032\u884c\u5206\u985e\u3002<\/li>\n<\/ul>\n<h3 id=\"2-%e6%95%99%e5%ad%b8%e8%88%87%e7%a0%94%e7%a9%b6-QXYzyVvwxj\">2. \u6559\u5b78\u8207\u7814\u7a76<\/h3>\n<p>MNIST\u6578\u64da\u5eab\u662f\u8a31\u591a\u6a5f\u5668\u5b78\u7fd2\u8ab2\u7a0b\u548c\u7814\u7a76\u7684\u57fa\u790e\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u500b\u7c21\u55ae\u7684\u74b0\u5883\uff0c\u8b93\u5b78\u751f\u548c\u7814\u7a76\u4eba\u54e1\u53ef\u4ee5\u5feb\u901f\u5be6\u9a57\u548c\u9a57\u8b49\u4ed6\u5011\u7684\u7b97\u6cd5\u3002\u8a31\u591a\u958b\u6e90\u6a5f\u5668\u5b78\u7fd2\u6846\u67b6\uff08\u5982TensorFlow\u548cPyTorch\uff09\u90fd\u63d0\u4f9b\u4e86\u5c0dMNIST\u6578\u64da\u96c6\u7684\u652f\u6301\uff0c\u4f7f\u5f97\u4f7f\u7528\u8005\u80fd\u5920\u8f15\u9b06\u52a0\u8f09\u548c\u8655\u7406\u6578\u64da\u3002<\/p>\n<h3 id=\"3-%e6%80%a7%e8%83%bd%e5%9f%ba%e6%ba%96-QXYzyVvwxj\">3. \u6027\u80fd\u57fa\u6e96<\/h3>\n<p>\u7531\u65bcMNIST\u6578\u64da\u96c6\u7684\u5ee3\u6cdb\u4f7f\u7528\uff0c\u8a31\u591a\u7814\u7a76\u8005\u5c07\u5176\u4f5c\u70ba\u6027\u80fd\u57fa\u6e96\u4f86\u6bd4\u8f03\u4e0d\u540c\u7b97\u6cd5\u7684\u6548\u679c\u3002\u9019\u4f7f\u5f97MNIST\u6210\u70ba\u6a5f\u5668\u5b78\u7fd2\u9818\u57df\u7684\u4e00\u500b\u91cd\u8981\u53c3\u8003\u9ede\u3002<\/p>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8mnist%e6%95%b8%e6%93%9a%e5%ba%ab-QXYzyVvwxj\">\u5982\u4f55\u4f7f\u7528MNIST\u6578\u64da\u5eab<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528Python\u548cKeras\u5eab\u4f86\u8a13\u7df4\u4e00\u500b\u7c21\u55ae\u7684\u795e\u7d93\u7db2\u7d61\u4ee5\u8b58\u5225MNIST\u6578\u64da\u96c6\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>\nimport tensorflow as tf\nfrom tensorflow.keras import layers, models\nfrom tensorflow.keras.datasets import mnist\n\n# \u8f09\u5165\u6578\u64da\u96c6\n(x_train, y_train), (x_test, y_test) = mnist.load_data()\n\n# \u6578\u64da\u9810\u8655\u7406\nx_train = x_train.reshape((60000, 28, 28, 1)).astype('float32') \/ 255\nx_test = x_test.reshape((10000, 28, 28, 1)).astype('float32') \/ 255\n\n# \u5efa\u7acb\u6a21\u578b\nmodel = models.Sequential()\nmodel.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Conv2D(64, (3, 3), activation='relu'))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Flatten())\nmodel.add(layers.Dense(64, activation='relu'))\nmodel.add(layers.Dense(10, activation='softmax'))\n\n# \u7de8\u8b6f\u6a21\u578b\nmodel.compile(optimizer='adam',\n              loss='sparse_categorical_crossentropy',\n              metrics=['accuracy'])\n\n# \u8a13\u7df4\u6a21\u578b\nmodel.fit(x_train, y_train, epochs=5)\n\n# \u8a55\u4f30\u6a21\u578b\ntest_loss, test_acc = model.evaluate(x_test, y_test)\nprint('Test accuracy:', test_acc)\n<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-QXYzyVvwxj\">\u7d50\u8ad6<\/h2>\n<p>MNIST\u6578\u64da\u5eab\u4f5c\u70ba\u6a5f\u5668\u5b78\u7fd2\u9818\u57df\u7684\u91cd\u8981\u8cc7\u6e90\uff0c\u4e0d\u50c5\u70ba\u521d\u5b78\u8005\u63d0\u4f9b\u4e86\u5b78\u7fd2\u7684\u57fa\u790e\uff0c\u9084\u70ba\u7814\u7a76\u8005\u63d0\u4f9b\u4e86\u6027\u80fd\u57fa\u6e96\u3002\u901a\u904e\u5c0dMNIST\u6578\u64da\u96c6\u7684\u63a2\u7d22\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u6df1\u5165\u7406\u89e3\u6a5f\u5668\u5b78\u7fd2\u7684\u57fa\u672c\u6982\u5ff5\u548c\u6280\u8853\uff0c\u4e26\u5728\u6b64\u57fa\u790e\u4e0a\u9032\u4e00\u6b65\u767c\u5c55\u66f4\u8907\u96dc\u7684\u6a21\u578b\u548c\u61c9\u7528\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc\u96f2\u8a08\u7b97\u548c\u6578\u64da\u8655\u7406\u6709\u8208\u8da3\uff0c\u4e26\u5e0c\u671b\u5728\u9999\u6e2f\u5c0b\u627e\u5408\u9069\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u53c3\u8003\u6211\u5011\u7684<a href=\"https:\/\/server.hk\">VPS<\/a> \u670d\u52d9\uff0c\u70ba\u60a8\u7684\u6a5f\u5668\u5b78\u7fd2\u9805\u76ee\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22MNIST\u6578\u64da\u5eab\u5728\u6a5f\u5668\u5b78\u7fd2\u4e2d\u7684\u61c9\u7528\uff0c\u5b78\u7fd2\u5982\u4f55\u5229\u7528\u624b\u5beb\u6578\u5b57\u6578\u64da\u9032\u884c\u6a21\u578b\u8a13\u7df4\u8207\u8a55\u4f30\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-193533","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/193533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=193533"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/193533\/revisions"}],"predecessor-version":[{"id":193534,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/193533\/revisions\/193534"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=193533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=193533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=193533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}