{"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\/ja\/2017\/12\/06\/simple-example-tensorflow\/","title":{"rendered":"\u5358\u7d14\u306a TensorFlow \u306e\u4f8b"},"content":{"rendered":"<p>\u3053\u3053\u3067\u306f\u3001\u30c7\u30a3\u30fc\u30d7 \u30e9\u30fc\u30cb\u30f3\u30b0\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3059\u308b\u7c21\u5358\u306a\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002\u30c6\u30f3\u30bd\u30eb\u30d5\u30ed\u30fc\u3002\u3053\u306e\u4f8b\u3067\u306f\u3001\u30cb\u30e5\u30fc\u30e9\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u6b63\u3001\u8ca0\u306e\u6570\u3001\u304a\u3088\u3073\u30bc\u30ed\u3092\u691c\u51fa\u3059\u308b\u3088\u3046\u6559\u3048\u307e\u3059\u3002 <a href=\"https:\/\/www.tensorflow.org\/\" target=\"_blank\" rel=\"noopener\">TensorFlow<\/a> \u3068 <a href=\"https:\/\/developer.nvidia.com\/\" \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30ebcuda -downloads\" target=\"_blank\" rel=\"noopener\">CUDA<\/a> \u6559\u3048\u3066\u304a\u304d\u307e\u3059\u304c\u3001\u3053\u306e\u30bf\u30b9\u30af\u306f\u5b9f\u969b\u306b\u306f\u7c21\u5358\u3067\u306f\u3042\u308a\u307e\u305b\u3093)<\/p>\n<p>\u5206\u985e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u306b\u306f\u3001<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 \u300d target=\"_blank\" rel=\"noopener\">\u5206\u985e\u5b50<\/a>\u3002 <a href=\"https:\/\/www.tensorflow.org\/\" target=\"_blank\" rel=\"noopener\">TensorFlow<\/a> \u306b\u306f\u3001\u6700\u5c0f\u9650\u306e\u69cb\u6210\u3067\u52d5\u4f5c\u3059\u308b\u65e2\u88fd\u306e\u9ad8\u30ec\u30d9\u30eb\u5206\u985e\u5668\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002\u307e\u305a\u3001<a href=\"https:\/\/www.tensorflow.org\/versions\/master\/api_docs\/python\/tf\/estimator\/DNNClassifier\" target=\"_blank\" rel=\"noopener\">DNNClassifier<\/a> \u3092\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u3057\u307e\u3059\u3002\u6b63\u3001\u8ca0\u306e\u6570\u5024\u3001\u30bc\u30ed\u3092\u542b\u3080\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u6b63\u3057\u3044\u300c\u30e9\u30d9\u30eb\u300d\u3092\u4ed8\u3051\u3066\u304f\u3060\u3055\u3044\u3002\u4eba\u9593\u306e\u30ec\u30d9\u30eb\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306f\u5206\u985e\u7d50\u679c (\u30e9\u30d9\u30eb) \u3092\u542b\u3080\u4e00\u9023\u306e\u6570\u5024\u3067\u3059\u3002<\/p>\n<p><strong><em>10 &#8211;\u30dd\u30b8\u30c6\u30a3\u30d6<\/em><\/strong><br \/><strong><em>-22 &#8211;\u30cd\u30ac\u30c6\u30a3\u30d6<\/em><\/strong><br \/><strong><em>0 &#8211;\u30bc\u30ed<\/em><\/strong><br \/><strong><em>42 &#8211;\u30dd\u30b8\u30c6\u30a3\u30d6<br \/> \u306a&#8230;\u5206\u985e\u306e\u3042\u308b\u305d\u306e\u4ed6\u306e\u756a\u53f7<br \/><\/em><\/strong><br \/>\u6b21\u306b\u3001\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u304c\u958b\u59cb\u3055\u308c\u3001\u305d\u306e\u5f8c\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u3082\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u6570\u5024\u3092\u5165\u529b\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u30cb\u30e5\u30fc\u30e9\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306f\u305d\u308c\u3089\u3092\u6b63\u3057\u304f\u8b58\u5225\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\u4ee5\u4e0b\u306f\u3001\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u304a\u3088\u3073\u5165\u529b\u30c7\u30fc\u30bf\u7528\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8 \u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc\u3092\u5099\u3048\u305f\u5206\u985e\u5b50\u306e\u5b8c\u5168\u306a\u30b3\u30fc\u30c9\u3067\u3059\u3002<br \/><!-- hilite.me \u3092\u4f7f\u7528\u3057\u3066\u751f\u6210\u3055\u308c\u305f HTML --><\/p>\n<div style=\"background: #ffffff; \u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc: \u81ea\u52d5; \u5e45: \u81ea\u52d5; \u30dc\u30fc\u30c0\u30fc: \u30bd\u30ea\u30c3\u30c9\u30b0\u30ec\u30fc; \u30dc\u30fc\u30c0\u30fc\u5e45: .1em .1em .1em .8em; \u30d1\u30c7\u30a3\u30f3\u30b0: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight:\u5927\u80c6\u306a;\">\u30a4\u30f3\u30dd\u30fc\u30c8<\/span> <span style=\"color: #0e84b5 ; font-weight: \u30dc\u30fc\u30eb\u30c9;\">\u30c6\u30f3\u30bd\u30eb\u30d5\u30ed\u30fc<\/span><span style=\"color: #008800; font-weight:bold;\">\u30a4\u30f3\u30dd\u30fc\u30c8<\/span> <span style=\"color: #0e84b5; font-weight:bold;\">itertools<\/span><span style=\"color: #008800; font-weight:bold;\">\u30a4\u30f3\u30dd\u30fc\u30c8<\/span><span style=\"color: #0e84b5; font-weight:bold;\">\u30e9\u30f3\u30c0\u30e0<\/span><span style=\"color: #008800; font-weight:bold;\">\u304b\u3089<\/span><span style=\"color: #0e84b5; font-weight:bold;\">\u6642\u523b<\/span> <span style= \"color: #008800; font-weight: ballad;\">\u30a4\u30f3\u30dd\u30fc\u30c8<\/span>\u6642\u9593<span style=\"color: #008800; font-weight:bold;\">\u30af\u30e9\u30b9<\/span> <span style=\"color: #bb0066; font-weight:bold;\">\u5206\u985e\u756a\u53f7<\/span>:__number <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: ballad;\">0<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight:bold;\">3<\/span><span style=\"color: #008800; font-weight:bold;\">def<\/span> <span style=\"color: #0066bb; font-weight:bold;\">__init__<\/span>(<span style =\"color: #007020;\">\u81ea\u5206<\/span>\u3001\u756a\u53f7):<span style=\"color: #007020;\">\u81ea\u5206<\/span><span style=\"color: #333333;\">.<\/span>__number <span style=\"color: #333333;\">=<\/\u30b9\u30d1\u30f3>\u6570\u5024<span style=\"color: #008800; font-weight:bold;\">if<\/span> \u6570\u5024 <span style=\"color: #333333;\">==<\/span> <span style=\"color: # 0000dd; font-weight: \u592a\u5b57;\">0<\/span>:<span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/\u30b9\u30d1\u30f3> <\u30b9\u30d1\u30f3 \u30b9\u30bf\u30a4\u30eb=\"\u30ab\u30e9\u30fc: #0000dd; font-weight: \u30dc\u30fc\u30eb\u30c9;\">0<\/span> <\u30b9\u30d1\u30f3 \u30b9\u30bf\u30a4\u30eb=\"\u30ab\u30e9\u30fc: #888888;\">#\u30bc\u30ed<span style=\"color: #008800; font-weight:bold;\">\u30a8\u30ea\u30d5<\/span> \u756a\u53f7 <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: # 0000dd; font-weight: \u592a\u5b57;\">0<\/span>:<span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/\u30b9\u30d1\u30f3> <\u30b9\u30d1\u30f3 \u30b9\u30bf\u30a4\u30eb=\"\u30ab\u30e9\u30fc: #0000dd; font-weight: \u30dc\u30fc\u30eb\u30c9;\">1<\/span> <\u30b9\u30d1\u30f3 \u30b9\u30bf\u30a4\u30eb=\"\u30ab\u30e9\u30fc: #888888;\">#\u30dd\u30b8\u30c6\u30a3\u30d6<\/\u30b9\u30d1\u30f3><span style=\"color: #008800; font-weight:bold;\">\u30a8\u30ea\u30d5<\/span> \u756a\u53f7 <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: # 0000dd; font-weight: \u592a\u5b57;\">0<\/span>:<span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/\u30b9\u30d1\u30f3> <\u30b9\u30d1\u30f3 \u30b9\u30bf\u30a4\u30eb=\"\u30ab\u30e9\u30fc: #0000dd; font-weight: \u30dc\u30fc\u30eb\u30c9;\">2<\/span> <\u30b9\u30d1\u30f3 \u30b9\u30bf\u30a4\u30eb=\"\u30ab\u30e9\u30fc: #888888;\">#\u5426\u5b9a\u7684<\/span><span style=\"color: #008800; font-weight:bold;\">def<\/span> <span style=\"color: #0066bb; font-weight:bold;\">\u6570\u5024<\/span>(<span style =\"color: #007020;\">\u81ea\u5206<\/span>):<span style=\"color: #008800; font-weight:bold;\">\u623b\u308b<\/span> <span style=\"color: #007020;\">\u81ea\u5206\u81ea\u8eab<\/span><span style=\"color: #333333; \">.<\/span>__\u756a\u53f7<span style=\"color: #008800; font-weight:bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: ballad;\">classifiedAs<\/span>(<span style =\"color: #007020;\">\u81ea\u5206<\/span>):<span style=\"color: #008800; font-weight:bold;\">\u623b\u308b<\/span> <span style=\"color: #007020;\">\u81ea\u5206\u81ea\u8eab<\/span><span style=\"color: #333333; \">.<\/span>__classifiedAs<span style=\"color: #008800; font-weight:bold;\">def<\/span> <span style=\"color: #0066bb; font-weight:bold;\">classifiedAsString<\/span>(classifiedAs):<span style=\"color: #008800; font-weight:bold;\">if<\/span> \u3068\u3057\u3066\u5206\u985e<span style=\"color: #333333;\">==<\/span> <span style=\"color: # 0000dd; font-weight: \u592a\u5b57;\">0<\/span>:<span style=\"color: #008800; font-weight:bold;\">return<\/span> <span style=\"background-color: #fff0f0;\">\u300c\u30bc\u30ed\u300d<\/span><span style=\"color: #008800; font-weight:bold;\">elif<\/span> \u304c <span style=\"color: #333333;\">==<\/span> \u3068\u3057\u3066\u5206\u985e\u3055\u308c\u307e\u3057\u305f <span style=\"color: # 0000dd; font-weight: \u592a\u5b57;\">1<\/span>:<span style=\"color: #008800; font-weight:bold;\">return<\/span> <span style=\"background-color: #fff0f0;\">\u300c\u30dd\u30b8\u30c6\u30a3\u30d6\u300d<\/span><span style=\"color: #008800; font-weight:bold;\">elif<\/span> \u304c <span style=\"color: #333333;\">==<\/span> \u3068\u3057\u3066\u5206\u985e\u3055\u308c\u307e\u3057\u305f <span style=\"color: # 0000dd; font-weight: \u592a\u5b57;\">2<\/span>:<span style=\"color: #008800; font-weight: ballad;\">return<\/span> <span style=\"background-color: #fff0f0;\">\"Negative\"<\/span><span style=\"color: #008800; font-weight:bold;\">def<\/span> <span style=\"color: #0066bb; font-weight:bold;\">trainDatasetFunction<\/span>():trainNumbers <span style=\"color: #333333;\">=<\/span> []trainNumberLabels <span style=\"color: #333333;\">=<\/span> []<span style=\"color: #008800; font-weight:bold;\">\u79c1\u306f<\/span><span style=\"color: #000000; font-weight:bold;\">\u4e2d<\/span> <span style =\"color: #007020;\">\u7bc4\u56f2<\/span>(<span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: \u30dc\u30fc\u30eb\u30c9;\">1000<\/span>\u3001<span style=\"color: #0000dd;\">1001<\/span>):\u6570\u5024 <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=\"color: #008800; font-weight:bold;\">return<\/span> ( {<span style=\"background-color: #fff0f0;\">\"number\"<\/span> : trainNumbers } , trainNumberLabels)<span style=\"color: #008800; font-weight: ballad;\">def<\/span> <span style=\"color: #0066bb; font-weight: ballad;\">inputDatasetFunction<\/span>():<span style=\"color: #008800; font-weight: ballad;\">\u30b0\u30ed\u30fc\u30d0\u30eb<\/span> \u30e9\u30f3\u30c0\u30e0\u30b7\u30fc\u30c9random<span style=\"color: #333333;\">.<\/span>seed(randomSeed) <span style=\"color: #888888;\"># \u540c\u3058\u7d50\u679c\u3092\u5f97\u308b<\/span>\u6570\u5b57<span style=\"color: #333333;\">=<\/span> []<span style=\"color: #008800; font-weight:bold;\">\u79c1\u306f<\/span><span style=\"color: #000000; font-weight:bold;\">\u4e2d<\/span> <span style =\"color: #007020;\">\u7bc4\u56f2<\/span>(<span style=\"color: #0000dd; font-weight: ballad;\">0<\/span>, <span style=\"color: #0000dd; font-weight:\u5927\u80c6\u306a;\">4<\/span>):\u6570\u5024<span style=\"color: #333333;\">.<\/span>append(random<span style=\"color: #333333;\">.<\/span>randint(<span style=\"color: #333333; \">-<\/span><span style=\"color: #0000dd; font-weight: bulled;\">9999999<\/span>\u3001<span style=\"color: #0000dd; \u30d5\u30a9\u30f3\u30c8\u306e\u592a\u3055: \u592a\u5b57;\">9999999<\/span>))<span style=\"color: #008800; font-weight:bold;\">return<\/span> {<span style=\"background-color: #fff0f0;\">\"number\"<\/span> : \u6570\u5024 }<span style=\"color: #008800; font-weight:bold;\">def<\/span> <span style=\"color: #0066bb; font-weight:bold;\">\u30e1\u30a4\u30f3<\/span>():<span style=\"color: #007020;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"TensorFlow \u6b63\u8ca0\u30bc\u30ed\u6570\u5024\u5206\u985e\u5b50\u30c6\u30b9\u30c8 (demensdeum 2017 \u306b\u3088\u308b) (demensdeum@gmail. com)\"<\/span>)maximalClassesCount <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">len<\/span>(<span style=\"color: #007020;\">set< \/span>(trainDatasetFunction()[<span style=\"color: #0000dd; font-weight: bubble;\">1<\/span>])) <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: ballad;\">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\u5024\"<\/span>)\u5206\u985e\u5b50<span style=\"color: #333333;\">=<\/span> tensorflow<span style=\"color: #333333;\">.<\/span>\u63a8\u5b9a\u5b50<span style=\"color: #333333;\">\u3002 <\/span>DNNClassifier(feature_columns <span style=\"color: #333333;\">=<\/span> [numberFeature], hidden_\u200b\u200bunits <span style=\"color: #333333;\">=<\/span> [<span style=\"color: #0000dd; font-weight: ballad;\">10<\/span>\u3001<span style=\"color: # 0000dd; font-weight:bolold;\">20<\/span>\u3001<span style=\"color: #0000dd:bold;\">10<\/span>]\u3001n_classes <span style=\"color: #333333;\">=<\/span> maximalClassesCount)\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc<span style=\"color: #333333;\">=<\/span> \u5206\u985e\u5b50<span style=\"color: #333333;\">.<\/span>train(input_fn <span style=\"color: #333333;\" >=<\/span> trainDatasetFunction\u3001\u30b9\u30c6\u30c3\u30d7 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: \u592a\u5b57;\">1000<\/span>)<span style=\"color: #333333;\">.<\/span>predict(input_fn <span style=\"color: #333333;\">= <\/span> inputDatasetFunction)inputDataset <span style=\"color: #333333;\">=<\/span> inputDatasetFunction()\u7d50\u679c <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">\u30ea\u30b9\u30c8<\/span>(itertools<span style=\"color: #333333;\">)\u3002 <\/span>islice(generator, <span style=\"color: #007020;\">len<\/span>(inputDatasetFunction()[<span style=\"background-color: #fff0f0;\">\"\u6570\u5024\"<\/span>])))i <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: ballad;\">0<\/span><span style=\"color: #008800; font-weight:bold;\">\u7d50\u679c\u306e<span style=\"color: #000000; font-weight:bold;\">\u7d50\u679c<\/span>:<span style=\"color: #007020;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"\u756a\u53f7: %d \u306f %s \u3068\u3057\u3066\u5206\u985e\u3055\u308c\u307e\u3057\u305f\"<\/span> <span style= \"color: #333333;\">%<\/span> (inputDataset[<span style=\"background-color: #fff0f0;\">\"number\"<\/span>][i], generatedAsString(result[<span style=\"background-color: #fff0f0;\">\"class_ids\"<\/span>][<span style=\"color: #0000dd; font-weight: ballad;\">0<\/span> ])))i <span style=\"color: #333333;\">+=<\/span> <span style=\"color: #0000dd; font-weight: HD;\">1<\/span>\u30e9\u30f3\u30c0\u30e0\u30b7\u30fc\u30c9 <span style=\"color: #333333;\">=<\/span> time()\u4e3b\u8981\uff08\uff09<\/pre>\n<\/div>\n<p>\u3059\u3079\u3066\u306f main() \u30e1\u30bd\u30c3\u30c9\u3067\u59cb\u307e\u308a\u3001\u5206\u985e\u5b50\u304c\u6a5f\u80fd\u3059\u308b\u6570\u5024\u5217\u3092\u8a2d\u5b9a\u3057\u307e\u3059 &#8211; <strong>tensorflow.feature_column.numeric_column(&#8220;number&#8221;)<\/strong> \u6b21\u306b\u3001\u5206\u985e\u5b50\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002 API \u306f\u6bce\u65e5\u5909\u66f4\u3055\u308c\u308b\u305f\u3081\u3001\u73fe\u5728\u306e\u521d\u671f\u5316\u5f15\u6570\u3092\u8aac\u660e\u3059\u308b\u3053\u3068\u306f\u5f79\u306b\u7acb\u3061\u307e\u305b\u3093\u3002\u53e4\u3044\u30de\u30cb\u30e5\u30a2\u30eb\u306b\u4f9d\u5b58\u305b\u305a\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u30d0\u30fc\u30b8\u30e7\u30f3\u306e TensorFlow \u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u5fc5\u305a\u53c2\u7167\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u6b63\u3001\u8ca0\u3001\u307e\u305f\u306f\u30bc\u30ed\u306b\u57fa\u3065\u3044\u3066\u3053\u308c\u3089\u306e\u6570\u5024\u3092\u6b63\u3057\u304f\u5206\u985e\u3057\u3066\u3001-1000 \u304b\u3089 1000 \u307e\u3067\u306e\u6570\u5024\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u8fd4\u3059\u95a2\u6570 (<strong>trainDatasetFunction<\/strong>) \u3092\u793a\u3059\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u304c\u958b\u59cb\u3055\u308c\u307e\u3059\u3002\u6b21\u306b\u3001\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0 \u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u6570\u5024\u3092\u5165\u529b\u3068\u3057\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002 -9999999 \u304b\u200b\u200b\u3089 9999999 \u307e\u3067\u306e\u30e9\u30f3\u30c0\u30e0 (<strong>inputDatasetFunction<\/strong>) \u3092\u4f7f\u7528\u3057\u3066\u5206\u985e\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u3001\u5165\u529b\u30c7\u30fc\u30bf (<strong>itertools.islice<\/strong>) \u306e\u6570\u306b\u57fa\u3065\u3044\u3066\u53cd\u5fa9\u3092\u958b\u59cb\u3057\u3001\u7d50\u679c\u3092\u51fa\u529b\u3057\u3066\u5b9f\u884c\u3059\u308b\u3068\u3001\u9a5a\u304f\u3079\u304d\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<p><!-- hilite.me \u3092\u4f7f\u7528\u3057\u3066\u751f\u6210\u3055\u308c\u305f HTML --><\/p>\n<div style=\"background: #ffffff; \u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc: \u81ea\u52d5; \u5e45: \u81ea\u52d5; \u30dc\u30fc\u30c0\u30fc: \u30bd\u30ea\u30c3\u30c9\u30b0\u30ec\u30fc; \u30dc\u30fc\u30c0\u30fc\u5e45: .1em .1em .1em .8em; \u30d1\u30c7\u30a3\u30f3\u30b0: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\">\u756a\u53f7: 4063470 \u306f\u967d\u6027\u3068\u3057\u3066\u5206\u985e\u3055\u308c\u307e\u3057\u305f\u756a\u53f7: 6006715 \u967d\u6027\u3068\u3057\u3066\u5206\u985e\u756a\u53f7: -5367127 \u306f\u9670\u6027\u3068\u3057\u3066\u5206\u985e\u3055\u308c\u307e\u3057\u305f\u756a\u53f7: -7834276 \u9670\u6027\u3068\u3057\u3066\u5206\u985e<\/pre>\n<\/div>\n<blockquote class=\"imgur-embed-pub\" lang=\"en\" data-id=\"mTS5bXR\">\n<p><a href=\"\/\/imgur.com\/mTS5bXR\">iT&#8217;S ALIVE<\/a <\/p>\n<\/blockquote>\n<p><script async src=\"\/\/s.imgur.com\/min\/embed.js\" charset=\"utf-8\"><\/script><\/p>\n<p>\u6b63\u76f4\u306b\u8a00\u3046\u3068\u3001\u79c1\u304c\u6559\u3048\u3066\u3044\u306a\u3044\u6570\u5024\u3055\u3048\u3082\u5206\u985e\u5b50\u304c\u300c\u7406\u89e3\u300d\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u4eca\u3067\u3082\u5c11\u3057\u9a5a\u3044\u3066\u3044\u307e\u3059\u3002\u5c06\u6765\u7684\u306b\u306f\u3001\u6a5f\u68b0\u5b66\u7fd2\u306e\u30c8\u30d4\u30c3\u30af\u3092\u3088\u308a\u8a73\u7d30\u306b\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u3088\u308a\u591a\u304f\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u304c\u63d0\u4f9b\u3055\u308c\u308b\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>GitLab:<br \/><a href=\"https:\/\/gitlab.com\/demensdeum\/MachineLearning\" target=\"_blank\" rel=\"noopener\">https:\/\/gitlab.com\/demensdeum\/MachineLearning<\/a><\/p>\n<p>\u30ea\u30f3\u30af:<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>\u3053\u3053\u3067\u306f\u3001\u30c7\u30a3\u30fc\u30d7 \u30e9\u30fc\u30cb\u30f3\u30b0\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3059\u308b\u7c21\u5358\u306a\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002\u30c6\u30f3\u30bd\u30eb\u30d5\u30ed\u30fc\u3002\u3053\u306e\u4f8b\u3067\u306f\u3001\u30cb\u30e5\u30fc\u30e9\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u6b63\u3001\u8ca0\u306e\u6570\u3001\u304a\u3088\u3073\u30bc\u30ed\u3092\u691c\u51fa\u3059\u308b\u3088\u3046\u6559\u3048\u307e\u3059\u3002 TensorFlow \u3068 \u5206\u985e\u5b50\u3002 TensorFlow \u306b\u306f\u3001\u6700\u5c0f\u9650\u306e\u69cb\u6210\u3067\u52d5\u4f5c\u3059\u308b\u65e2\u88fd\u306e\u9ad8\u30ec\u30d9\u30eb\u5206\u985e\u5668\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002\u307e\u305a\u3001DNNClassifier \u3092\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u3057\u307e\u3059\u3002\u6b63\u3001\u8ca0\u306e\u6570\u5024\u3001\u30bc\u30ed\u3092\u542b\u3080\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u6b63\u3057\u3044\u300c\u30e9\u30d9\u30eb\u300d\u3092\u4ed8\u3051\u3066\u304f\u3060\u3055\u3044\u3002\u4eba\u9593\u306e\u30ec\u30d9\u30eb\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306f\u5206\u985e\u7d50\u679c (\u30e9\u30d9\u30eb) \u3092\u542b\u3080\u4e00\u9023\u306e\u6570\u5024\u3067\u3059\u3002 10 &#8211;\u30dd\u30b8\u30c6\u30a3\u30d6-22 &#8211;\u30cd\u30ac\u30c6\u30a3\u30d60 &#8211;\u30bc\u30ed42 &#8211;\u30dd\u30b8\u30c6\u30a3\u30d6 \u306a&#8230;\u5206\u985e\u306e\u3042\u308b\u305d\u306e\u4ed6\u306e\u756a\u53f7\u6b21\u306b\u3001\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u304c\u958b\u59cb\u3055\u308c\u3001\u305d\u306e\u5f8c\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u3082\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u6570\u5024\u3092\u5165\u529b\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u30cb\u30e5\u30fc\u30e9\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306f\u305d\u308c\u3089\u3092\u6b63\u3057\u304f\u8b58\u5225\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u304a\u3088\u3073\u5165\u529b\u30c7\u30fc\u30bf\u7528\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8 \u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc\u3092\u5099\u3048\u305f\u5206\u985e\u5b50\u306e\u5b8c\u5168\u306a\u30b3\u30fc\u30c9\u3067\u3059\u3002 \u30a4\u30f3\u30dd\u30fc\u30c8 \u30c6\u30f3\u30bd\u30eb\u30d5\u30ed\u30fc\u30a4\u30f3\u30dd\u30fc\u30c8 itertools\u30a4\u30f3\u30dd\u30fc\u30c8\u30e9\u30f3\u30c0\u30e0\u304b\u3089\u6642\u523b \u30a4\u30f3\u30dd\u30fc\u30c8\u6642\u9593\u30af\u30e9\u30b9 \u5206\u985e\u756a\u53f7:__number = 0__classifiedAs = 3def __init__(\u81ea\u5206\u3001\u756a\u53f7):\u81ea\u5206.__number =\u6570\u5024if \u6570\u5024 == 0:self.__classifiedAs = 0 #\u30bc\u30ed\u30a8\u30ea\u30d5 \u756a\u53f7 &gt; 0:self.__classifiedAs = 1 #\u30dd\u30b8\u30c6\u30a3\u30d6\u30a8\u30ea\u30d5 \u756a\u53f7 &lt; 0:self.__classifiedAs = 2 #\u5426\u5b9a\u7684def \u6570\u5024(\u81ea\u5206):\u623b\u308b \u81ea\u5206\u81ea\u8eab.__\u756a\u53f7def classifiedAs(\u81ea\u5206):\u623b\u308b \u81ea\u5206\u81ea\u8eab.__classifiedAsdef classifiedAsString(classifiedAs):if \u3068\u3057\u3066\u5206\u985e== 0:return<a class=\"more-link\" href=\"https:\/\/demensdeum.com\/blog\/ja\/2017\/12\/06\/simple-example-tensorflow\/\">Continue reading <span class=\"screen-reader-text\">&#8220;\u5358\u7d14\u306a TensorFlow \u306e\u4f8b&#8221;<\/span><\/a><\/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":"ja","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\/ja\/wp-json\/wp\/v2\/posts\/1258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/comments?post=1258"}],"version-history":[{"count":26,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/1258\/revisions"}],"predecessor-version":[{"id":3988,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/1258\/revisions\/3988"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/media?parent=1258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/categories?post=1258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/tags?post=1258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}