{"id":1258,"date":"2017-12-06T21:18:07","date_gmt":"2017-12-06T21:18:07","guid":{"rendered":"http:\/\/demensdeum.com\/blog\/?p=1258"},"modified":"2024-12-16T22:32:44","modified_gmt":"2024-12-16T19:32:44","slug":"simple-example-tensorflow","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/zh\/2017\/12\/06\/simple-example-tensorflow\/","title":{"rendered":"\u7b80\u5355\u7684 TensorFlow \u793a\u4f8b"},"content":{"rendered":"<p>\u6211\u5411\u60a8\u5c55\u793a\u4e00\u4e2a\u4f7f\u7528\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u7684\u7b80\u5355\u793a\u4f8b &#8211; TensorFlow\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u6559\u795e\u7ecf\u7f51\u7edc\u68c0\u6d4b\u6b63\u6570\u3001\u8d1f\u6570\u548c\u96f6\u3002\u5b89\u88c5 <a href=\"https:\/\/www.tensorflow.org\/\" target=\"_blank\" rel=\"noopener\">TensorFlow<\/a> \u548c <a href=\"https:\/\/developer.nvidia.com\/ cuda -downloads\" target=\"_blank\" rel=\"noopener\">CUDA<\/a>\u6211\u544a\u8bc9\u4f60\uff0c\u8fd9\u4e2a\u4efb\u52a1\u771f\u7684\u4e0d\u662f\u4e00\u4ef6\u5bb9\u6613\u7684\u4e8b\uff09<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u5206\u7c7b\u95ee\u9898\uff0c<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B0_%D0 %BA%D0%BB%D0%B0%D1%81%D1%81%D0%B8%D1%84%D0%B8%D0%BA%D0%B0%D1%86%D0%B8%D0%B8 \u201d target=\"_blank\" rel=\"noopener\">\u5206\u7c7b\u5668<\/a>\u3002 <a href=\"https:\/\/www.tensorflow.org\/\" target=\"_blank\" rel=\"noopener\">TensorFlow<\/a> \u6709\u51e0\u4e2a\u73b0\u6210\u7684\u9ad8\u7ea7\u5206\u7c7b\u5668\uff0c\u53ea\u9700\u6700\u5c11\u7684\u914d\u7f6e\u5373\u53ef\u5de5\u4f5c\u3002\u9996\u5148\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u8bad\u7ec3 <a href=\"https:\/\/www.tensorflow.org\/versions\/master\/api_docs\/python\/tf\/estimator\/DNNClassifier\" target=\"_blank\" rel=\"noopener\">DNNClassifier<\/a>\u5177\u6709\u6b63\u6570\u3001\u8d1f\u6570\u548c\u96f6\u7684\u6570\u636e\u96c6\u5177\u6709\u6b63\u786e\u7684\u201c\u6807\u7b7e\u201d\u3002\u5728\u4eba\u7c7b\u5c42\u9762\uff0c\u6570\u636e\u96c6\u662f\u4e00\u7ec4\u5e26\u6709\u5206\u7c7b\u7ed3\u679c\uff08\u6807\u7b7e\uff09\u7684\u6570\u5b57\uff1a<\/p>\n<p><strong><em>10 &#8211;\u79ef\u6781<\/em><\/strong><br \/><strong><em>-22 &#8211;\u8d1f\u9762<\/em><\/strong><br \/><strong><em>0 &#8211;\u96f6<\/em><\/strong><br \/><strong><em>42 &#8211;\u79ef\u6781<br \/>&#8230;\u5176\u4ed6\u6709\u5206\u7c7b\u7684\u53f7\u7801<br \/><\/em><\/strong><br \/>\u63a5\u4e0b\u6765\uff0c\u8bad\u7ec3\u5f00\u59cb\uff0c\u4e4b\u540e\u60a8\u53ef\u4ee5\u8f93\u5165\u6570\u636e\u96c6\u4e2d\u672a\u5305\u542b\u7684\u6570\u5b57 \u2013\u795e\u7ecf\u7f51\u7edc\u5fc5\u987b\u6b63\u786e\u8bc6\u522b\u5b83\u4eec\u3002<br \/>\u4e0b\u9762\u662f\u5206\u7c7b\u5668\u7684\u5b8c\u6574\u4ee3\u7801\uff0c\u5e26\u6709\u7528\u4e8e\u8bad\u7ec3\u548c\u8f93\u5165\u6570\u636e\u7684\u6570\u636e\u96c6\u751f\u6210\u5668\uff1a<br \/><!-- \u4f7f\u7528 hilite.me \u751f\u6210\u7684 HTML --><\/p>\n<div style=\"\u80cc\u666f\uff1a#ffffff\uff1b\u6ea2\u51fa\uff1a\u81ea\u52a8\uff1b\u5bbd\u5ea6\uff1a\u81ea\u52a8\uff1b\u8fb9\u6846\uff1a\u7eaf\u7070\u8272\uff1b\u8fb9\u6846\u5bbd\u5ea6\uff1a.1em .1em .1em .8em\uff1b\u586b\u5145\uff1a.2em .6em\uff1b\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">\u5bfc\u5165<\/span> <span style=\"color: #0e84b5 ; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">\u5f20\u91cf\u6d41<\/span><span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u5bfc\u5165<\/span> <span style=\u201ccolor\uff1a#0e84b5; font-weight\uff1abold;\u201d>itertools<\/span><span style =\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u5bfc\u5165<\/span> <span style =\u201ccolor\uff1a#0e84b5; font-weight\uff1abold;\u201d>\u968f\u673a<\/span><span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u6765\u81ea<\/span> <span style=\u201ccolor\uff1a#0e84b5; font-weight\uff1abold;\u201d>\u65f6\u95f4<\/span> <span style= \u201c\u989c\u8272\uff1a#008800\uff1b\u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">\u5bfc\u5165<\/span>\u65f6\u95f4<span style =\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u7c7b<\/span> <span style =\u201ccolor\uff1a#bb0066; font-weight\uff1abold;\u201d>\u5206\u7c7b\u53f7<\/span>\uff1a__number <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">3<\/span><span style=\"color\uff1a#008800; font-weight\uff1abold;\">def<\/span> <span style=\"color\uff1a#0066bb; font-weight\uff1abold;\">__init__<\/span>(<span style =\"color: #007020;\">\u81ea\u6211<\/span>\uff0c\u6570\u5b57\uff09\uff1a<span style=\"color: #007020;\">\u81ea\u5df1<\/span><span style=\"color: #333333;\">.<\/span>__number <span style=\"color: #333333;\">=<\/\u8de8\u5ea6>\u6570\u5b57<span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u5982\u679c<\/span>\u6570\u5b57 <span style=\u201ccolor\uff1a#333333;\u201d>==<\/span> <span style=\u201ccolor\uff1a#\u201d 0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">0<\/span>\uff1a<span style=\"color: #007020;\">\u81ea\u6211<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/\u8de8\u5ea6> <\u8de8\u5ea6\u98ce\u683c=\u201c\u989c\u8272\uff1a#0000dd;\u5b57\u4f53\u91cd\u91cf\uff1a\u7c97\u4f53;\u201d> 0<\/\u8de8\u5ea6> <\u8de8\u5ea6\u98ce\u683c=\u201c\u989c\u8272\uff1a#888888;\u201d>#\u96f6<\/span><span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>elif<\/span> \u6570\u5b57 <span style=\u201ccolor\uff1a#333333;\u201d>&gt;<\/span> <span style=\u201ccolor\uff1a#\u201d 0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">0<\/span>\uff1a<span style=\"color: #007020;\">\u81ea\u6211<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/\u8de8\u5ea6> <\u8de8\u5ea6\u98ce\u683c=\u201c\u989c\u8272\uff1a#0000dd;\u5b57\u4f53\u91cd\u91cf\uff1a\u7c97\u4f53;\u201d> 1<\/\u8de8\u5ea6> <\u8de8\u5ea6\u98ce\u683c=\u201c\u989c\u8272\uff1a#888888;\u201d>#\u79ef\u6781<\/span><span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>elif<\/span>\u6570\u5b57 <span style=\u201ccolor\uff1a#333333;\u201d><<\/span> <span style=\u201ccolor\uff1a#\u201d 0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">0<\/span>\uff1a<span style=\"color: #007020;\">\u81ea\u6211<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/\u8de8\u5ea6> <\u8de8\u5ea6\u98ce\u683c=\u201c\u989c\u8272\uff1a#0000dd;\u5b57\u4f53\u91cd\u91cf\uff1a\u7c97\u4f53;\u201d> 2<\/\u8de8\u5ea6> <\u8de8\u5ea6\u98ce\u683c=\u201c\u989c\u8272\uff1a#888888;\u201d>#\u8d1f\u9762<\/span><span style=\"color\uff1a#008800; font-weight\uff1abold;\">def<\/span> <span style=\"color\uff1a#0066bb; font-weight\uff1abold;\">\u6570\u5b57<\/span>(<span style =\u201c\u989c\u8272\uff1a#007020;\u201d>\u81ea\u6211<\/span>\uff09\uff1a<span style =\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u8fd4\u56de<\/span> <span style =\u201ccolor\uff1a#007020;\u201d>\u81ea\u6211<\/span><span style =\u201ccolor\uff1a#333333;\u201d \">.<\/span>__\u53f7\u7801<span style=\"color\uff1a#008800; font-weight\uff1abold;\">def<\/span> <span style=\"color\uff1a#0066bb; font-weight\uff1abold;\">\u5206\u7c7b\u4e3a<\/span>(<span style =\u201c\u989c\u8272\uff1a#007020;\u201d>\u81ea\u6211<\/span>\uff09\uff1a<span style =\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u8fd4\u56de<\/span> <span style =\u201ccolor\uff1a#007020;\u201d>\u81ea\u6211<\/span><span style =\u201ccolor\uff1a#333333;\u201d \">.<\/span>__classifiedAs<span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>def<\/span> <span style=\u201ccolor\uff1a#0066bb; font-weight\uff1abold;\u201d>classifiedAsString<\/span>\uff08classifiedAs\uff09\uff1a<span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u5982\u679c<\/span>\u5206\u7c7b\u4e3a<span style=\u201ccolor\uff1a#333333;\u201d>==<\/span> <span style=\u201ccolor\uff1a#\u201d 0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">0<\/span>\uff1a<span style=\"color: #008800; font-weight: bold;\">\u8fd4\u56de<\/span> <span style=\"background-color: #fff0f0;\">\u201c\u96f6\u201d<\/span><span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>elif<\/span> \u5206\u7c7b\u4e3a <span style=\u201ccolor\uff1a#333333;\u201d>==<\/span> <span style=\u201ccolor\uff1a#\u201d 0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">1<\/span>\uff1a<span style=\"color: #008800; font-weight: bold;\">\u8fd4\u56de<\/span> <span style=\"background-color: #fff0f0;\">\u201c\u6b63\u201d<\/span><span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>elif<\/span> \u5206\u7c7b\u4e3a <span style=\u201ccolor\uff1a#333333;\u201d>==<\/span> <span style=\u201ccolor\uff1a#\u201d 0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">2<\/span>\uff1a<span style=\"color: #008800; font-weight: bold;\">\u8fd4\u56de<\/span> <span style=\"background-color: #fff0f0;\">\u201c\u8d1f\u201d<\/span><span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>def<\/span> <span style=\u201ccolor\uff1a#0066bb; font-weight\uff1abold;\u201d>trainDatasetFunction<\/span>\uff08\uff09\uff1atrainNumbers <span style=\"color: #333333;\">=<\/span> []trainNumberLabels <span style=\"color: #333333;\">=<\/span> []<span style=\"color: #008800; font-weight: bold;\">\u5bf9\u4e8e<\/span> i <span style=\"color: #000000; font-weight: bold;\">\u5728<\/span> <span style =\"color: #007020;\">\u8303\u56f4<\/span>(<span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd;\u5b57\u4f53\u91cd\u91cf\uff1a\u7c97\u4f53\uff1b\">1000<\/span>\uff0c<span style=\"color\uff1a#0000dd\uff1b\u5b57\u4f53\u91cd\u91cf\uff1a\u7c97\u4f53\uff1b\">1001<\/span>\uff09\uff1a\u6570\u5b57 <span style=\"color: #333333;\">=<\/span> ClassifiedNumber(i)trainNumbers<span style=\"color: #333333;\">.<\/span>append(number<span style=\"color: #333333;\">.<\/span>number())trainNumberLabels<span style=\"color: #333333;\">.<\/span>append(number<span style=\"color: #333333;\">.<\/span>classifiedAs())<span style =\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u8fd4\u56de<\/span>\uff08{<span style =\u201cbackground-color\uff1a#fff0f0;\u201d>\u201cnumber\u201d<\/span>\uff1atrainNumbers }\uff0c\u5217\u8f66\u7f16\u53f7\u6807\u7b7e\uff09<span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>def<\/span> <span style=\u201ccolor\uff1a#0066bb; font-weight\uff1abold;\u201d>inputDatasetFunction<\/span>\uff08\uff09\uff1a<span style=\"color: #008800; font-weight: bold;\">\u5168\u5c40<\/span> randomSeedrandom<span style=\"color: #333333;\">.<\/span>seed(randomSeed) <span style=\"color: #888888;\"># \u5f97\u5230\u76f8\u540c\u7684\u7ed3\u679c<\/span>\u6570\u5b57 <span style=\"color: #333333;\">=<\/span> []<span style =\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u5bf9\u4e8e<\/span>\u6211<span style =\u201ccolor\uff1a#000000; font-weight\uff1abold;\u201d>\u5728<\/span> <span\u6837\u5f0f=\"color: #007020;\">\u8303\u56f4<\/span>(<span style=\"color: #0000dd; font-weight:bold;\">0<\/span>, <span\u6837\u5f0f=\u201c\u989c\u8272\uff1a#0000dd\uff1b\u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\u201d>4<\/span>\uff09\uff1a\u6570\u5b57<span style=\"color: #333333;\">.<\/span>append(\u968f\u673a<span style=\"color: #333333;\">.<\/span>randint(<span style=\"color: #333333; \">-<\/span><span style=\"color: #0000dd; font-weight: \u7c97\u4f53;\">9999999<\/span>, <span style=\"color: #0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53\uff1b\">9999999<\/span>))<span style =\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>\u8fd4\u56de<\/span> {<span style =\u201cbackground-color\uff1a#fff0f0;\u201d>\u201c\u6570\u5b57\u201d<\/span>\uff1a\u6570\u5b57}<span style=\u201ccolor\uff1a#008800; font-weight\uff1abold;\u201d>def<\/span> <span style=\u201ccolor\uff1a#0066bb; font-weight\uff1abold;\u201d>main<\/span>\uff08\uff09\uff1a<span style=\"color: #007020;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"TensorFlow Positive-Negative-Zero \u6570\u5b57\u5206\u7c7b\u5668\u6d4b\u8bd5\uff0c\u7531 demensdeum 2017 (demensdeum@gmail. com)\"<\/span>)maximalClassesCount <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">len<\/span>(<span style=\"color: #007020;\">\u8bbe\u7f6e< \/span>(trainDatasetFunction()[<span style=\"color: #0000dd; font-weight: bold;\">1<\/span>])) <span\u6837\u5f0f=\u201c\u989c\u8272\uff1a#333333;\u201d>+<\/span> <span\u6837\u5f0f=\u201c\u989c\u8272\uff1a#0000dd; font-weight\uff1a\u7c97\u4f53;\u201d>1<\/span>numberFeature <span style=\"color: #333333;\">=<\/span>tensorflow<span style=\"color: #333333;\">.<\/span>feature_column<span style=\"color: #333333;\">\u3002 <\/span>numeric_column(<span style=\"background-color: #fff0f0;\">\"\u6570\u5b57\"<\/span>)\u5206\u7c7b\u5668 <span style=\"color: #333333;\">=<\/span> \u5f20\u91cf\u6d41<span style=\"color: #333333;\">.<\/span>\u4f30\u8ba1\u5668<span style=\"color: #333333;\">\u3002 <\/span>DNNClassifier(feature_columns <span style=\"color: #333333;\">=<\/span> [numberFeature]\uff0chidden_\u200b\u200bunits <span style=\"color: #333333;\">=<\/span> [<span style=\"color: #0000dd; font-weight: bold;\">10<\/span>, <span style=\"color: # 0000dd; \u5b57\u4f53\u91cd\u91cf\uff1a\u7c97\u4f53\uff1b\">20<\/span>\uff0c<span style=\"color\uff1a#0000dd\uff1b\u5b57\u4f53\u91cd\u91cf\uff1a\u7c97\u4f53\uff1b\">10<\/span>]\uff0cn_classes <span style=\"color: #333333;\">=<\/span> maximalClassesCount)\u751f\u6210\u5668 <span style=\"color: #333333;\">=<\/span> \u5206\u7c7b\u5668<span style=\"color: #333333;\">.<\/span>train(input_fn <span style=\"color: #333333;\" >=<\/span> trainDatasetFunction\uff0c\u6b65\u9aa4 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; \u5b57\u4f53\u7c97\u7ec6\uff1a\u7c97\u4f53;\">1000<\/span>)<span style=\"color: #333333;\">.<\/span>\u9884\u6d4b(input_fn <span style=\"color: #333333;\">= <\/span> \u8f93\u5165\u6570\u636e\u96c6\u51fd\u6570\uff09inputDataset <span style=\"color: #333333;\">=<\/span> inputDatasetFunction()\u7ed3\u679c <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">\u5217\u8868<\/span>(itertools<span style=\"color: #333333;\">\u3002 <\/span>islice(\u751f\u6210\u5668\uff0c<span style=\"color: #007020;\">len<\/span>(inputDatasetFunction()[<span\u6837\u5f0f=\u201c\u80cc\u666f\u989c\u8272\uff1a#fff0f0;\u201d>\u201c\u6570\u5b57\u201d<\/span>]\uff09\uff09\uff09\u6211 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #008800; font-weight: bold;\">for<\/span> \u7ed3\u679c <span style=\"color: #000000; font-weight: bold;\">in<\/span> \u7ed3\u679c\uff1a<span style=\"color: #007020;\">\u6253\u5370<\/span>(<span style=\"background-color: #fff0f0;\">\"\u7f16\u53f7\uff1a%d \u5206\u7c7b\u4e3a %s\"<\/span> <span style= \"\u989c\u8272\uff1a#333333;\">%<\/span> (inputDataset[<span style=\"background-color: #fff0f0;\">\"\u6570\u5b57\"<\/span>][i], classifiedAsString(\u7ed3\u679c[<span style=\"background-color: #fff0f0;\">\"class_ids\"<\/span>][<span style=\"color: #0000dd; font-weight: bold;\">0<\/span> ]\uff09\uff09\uff09\u6211 <span style=\"color: #333333;\">+=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>randomSeed <span style=\"color: #333333;\">=<\/span> time()\u4e3b\u8981\u7684\uff08\uff09<\/\u524d><\/div>\n<p>\u8fd9\u4e00\u5207\u90fd\u4ece main() \u65b9\u6cd5\u5f00\u59cb\uff0c\u6211\u4eec\u8bbe\u7f6e\u5206\u7c7b\u5668\u5c06\u4f7f\u7528\u7684\u6570\u5b57\u5217&#8211; <strong>tensorflow.feature_column.numeric_column(&#8220;number&#8221;)<\/strong> \u63a5\u4e0b\u6765\uff0c\u8bbe\u7f6e\u5206\u7c7b\u5668\u53c2\u6570\u3002\u63cf\u8ff0\u5f53\u524d\u7684\u521d\u59cb\u5316\u53c2\u6570\u662f\u6ca1\u6709\u7528\u7684\uff0c\u56e0\u4e3a API \u6bcf\u5929\u90fd\u5728\u53d8\u5316\uff0c\u4f60\u7edd\u5bf9\u5e94\u8be5\u67e5\u770b\u5df2\u5b89\u88c5\u7684 TensorFlow \u7248\u672c\u7684\u6587\u6863\uff0c\u800c\u4e0d\u662f\u4f9d\u8d56\u8fc7\u65f6\u7684\u624b\u518c\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u542f\u52a8\u8bad\u7ec3\uff0c\u6307\u793a\u8fd4\u56de\u4ece -1000 \u5230 1000 \u7684\u6570\u5b57\u6570\u636e\u96c6\u7684\u51fd\u6570 (<strong>trainDatasetFunction<\/strong>)\uff0c\u5e76\u6839\u636e\u6b63\u6570\u3001\u8d1f\u6570\u6216\u96f6\u5bf9\u8fd9\u4e9b\u6570\u5b57\u8fdb\u884c\u6b63\u786e\u5206\u7c7b\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u63d0\u4ea4\u8bad\u7ec3\u6570\u636e\u96c6\u4e2d\u4e0d\u5b58\u5728\u7684\u8f93\u5165\u6570\u5b57\u2014\u2014\u4ece -9999999 \u5230 9999999 (<strong>inputDatasetFunction<\/strong>) \u968f\u673a\u8fdb\u884c\u5206\u7c7b\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u6839\u636e\u8f93\u5165\u6570\u636e\u7684\u6570\u91cf\u542f\u52a8\u8fed\u4ee3\uff08<strong>itertools.islice<\/strong>\uff09\uff0c\u6253\u5370\u7ed3\u679c\uff0c\u8fd0\u884c\u5b83\uff0c\u4f60\u4f1a\u611f\u5230\u60ca\u8bb6\uff1a<\/p>\n<p><!-- \u4f7f\u7528 hilite.me \u751f\u6210\u7684 HTML --><\/p>\n<div style=\"\u80cc\u666f\uff1a#ffffff\uff1b\u6ea2\u51fa\uff1a\u81ea\u52a8\uff1b\u5bbd\u5ea6\uff1a\u81ea\u52a8\uff1b\u8fb9\u6846\uff1a\u7eaf\u7070\u8272\uff1b\u8fb9\u6846\u5bbd\u5ea6\uff1a.1em .1em .1em .8em\uff1b\u586b\u5145\uff1a.2em .6em\uff1b\">\n<pre style=\"margin: 0; line-height: 125%;\">number: 4063470 \u5206\u7c7b\u4e3a Positive\u7f16\u53f7\uff1a6006715 \u5206\u7c7b\u4e3a\u9633\u6027\u7f16\u53f7\uff1a-5367127 \u5206\u7c7b\u4e3a\u8d1f\u9762\u7f16\u53f7\uff1a-7834276 \u5206\u7c7b\u4e3a\u8d1f\u9762<\/\u524d><\/div>\n<blockquote class=\"imgur-embed-pub\" lang=\"en\" data-id=\"mTS5bXR\">\n<p><a href=\"\/\/imgur.com\/mTS5bXR\">iT \u8fd8\u6d3b\u7740<\/a <\/p>\n<p><\/\u5757\u5f15\u7528><\/p>\n<p><\u811a\u672c\u5f02\u6b65 src=\"\/\/s.imgur.com\/min\/embed.js\" charset=\"utf-8\"><\/script><\/p>\n<p>\u8bf4\u5b9e\u8bdd\uff0c\u6211\u4ecd\u7136\u6709\u70b9\u60ca\u8bb6\u5206\u7c7b\u5668\u201c\u7406\u89e3\u201d\u751a\u81f3\u90a3\u4e9b\u6211\u6ca1\u6709\u6559\u8fc7\u7684\u6570\u5b57\u3002\u6211\u5e0c\u671b\u5c06\u6765\u6211\u80fd\u66f4\u8be6\u7ec6\u5730\u4e86\u89e3\u673a\u5668\u5b66\u4e60\u8fd9\u4e2a\u4e3b\u9898\uff0c\u5e76\u4e14\u4f1a\u6709\u66f4\u591a\u6559\u7a0b\u3002<\/p>\n<p>GitLab\uff1a<br \/><a href=\"https:\/\/gitlab.com\/demensdeum\/MachineLearning\" target=\"_blank\" rel=\"noopener\">https:\/\/gitlab.com\/demensdeum\/MachineLearning<\/a><\/p>\n<p>\u94fe\u63a5\uff1a<br \/><a href=\"https:\/\/developers.googleblog.com\/2017\/09\/introducing-tensorflow-datasets.html\" target=\"_blank\" rel=\"noopener\">https:\/\/developers.googleblog.com\/2017\/09\/introducing-tensorflow-datasets.html<\/a><br \/>\n<a href=\"https:\/\/www.tensorflow.org\/versions\/master\/api_docs\/python\/tf\/estimator\/DNNClassifier\" target=\"_blank\" rel=\"noopener\">https:\/\/www.tensorflow.org\/versions\/master\/api_docs\/python\/tf\/estimator\/DNNClassifier<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u5411\u60a8\u5c55\u793a\u4e00\u4e2a\u4f7f\u7528\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u7684\u7b80\u5355\u793a\u4f8b &#8211; TensorFlow\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u6559\u795e\u7ecf\u7f51\u7edc\u68c0\u6d4b\u6b63\u6570\u3001\u8d1f\u6570\u548c\u96f6\u3002\u5b89\u88c5 TensorFlow \u548c CUDA\u6211\u544a\u8bc9\u4f60\uff0c\u8fd9\u4e2a\u4efb\u52a1\u771f\u7684\u4e0d\u662f\u4e00\u4ef6\u5bb9\u6613\u7684\u4e8b\uff09 \u4e3a\u4e86\u89e3\u51b3\u5206\u7c7b\u95ee\u9898\uff0c<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[61,52],"tags":[87,86],"class_list":["post-1258","post","type-post","status-publish","format-standard","hentry","category-techie","category-tutorials","tag-machine-learning","tag-tensorflow","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"zh","enabled_languages":["en","ru","zh","de","fr","ja","pt","hi"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"ru":{"title":true,"content":true,"excerpt":false},"zh":{"title":true,"content":true,"excerpt":false},"de":{"title":true,"content":true,"excerpt":false},"fr":{"title":true,"content":true,"excerpt":false},"ja":{"title":true,"content":true,"excerpt":false},"pt":{"title":true,"content":true,"excerpt":false},"hi":{"title":false,"content":false,"excerpt":false}}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts\/1258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/comments?post=1258"}],"version-history":[{"count":26,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts\/1258\/revisions"}],"predecessor-version":[{"id":3988,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts\/1258\/revisions\/3988"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/media?parent=1258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/categories?post=1258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/tags?post=1258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}