{"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\/ru\/2017\/12\/06\/simple-example-tensorflow\/","title":{"rendered":"\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 TensorFlow"},"content":{"rendered":"<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Deep Learning &#8211; TensorFlow. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0438\u0435, \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438 \u043d\u043e\u043b\u044c. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 <a href=\"https:\/\/www.tensorflow.org\/\" target=\"_blank\" rel=\"noopener\">TensorFlow<\/a> \u0438 <a href=\"https:\/\/developer.nvidia.com\/cuda-downloads\" target=\"_blank\" rel=\"noopener\">CUDA<\/a> \u044f \u043f\u043e\u0440\u0443\u0447\u0430\u044e \u0432\u0430\u043c, \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u0438\u0437 \u043b\u0435\u0433\u043a\u0438\u0445)<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f <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\" target=\"_blank\" rel=\"noopener\">\u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b<\/a>. <a href=\"https:\/\/www.tensorflow.org\/\" target=\"_blank\" rel=\"noopener\">TensorFlow<\/a> \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043f\u043e\u0442\u0440\u0435\u043d\u0438\u0440\u0443\u0435\u043c\u00a0<a href=\"https:\/\/www.tensorflow.org\/versions\/master\/api_docs\/python\/tf\/estimator\/DNNClassifier\" target=\"_blank\" rel=\"noopener\">DNNClassifier<\/a> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438 \u043d\u0443\u043b\u0435\u043c &#8211; \u0441 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 &#8220;\u043b\u0435\u0439\u0431\u043b\u0430\u043c\u0438&#8221;. \u041d\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043d\u0430\u0431\u043e\u0440 \u0447\u0438\u0441\u0435\u043b \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (\u043b\u0435\u0439\u0431\u043b\u0430\u043c\u0438):<\/p>\n<p><strong><em>10 &#8211; \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435<\/em><\/strong><br \/><strong><em>-22 &#8211; \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435<\/em><\/strong><br \/><strong><em>0 &#8211; \u043d\u043e\u043b\u044c<\/em><\/strong><br \/><strong><em>42 &#8211; \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435<br \/>&#8230; \u0434\u0440\u0443\u0433\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439<br \/><\/em><\/strong><br \/>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430 \u0432\u0445\u043e\u0434 \u0447\u0438\u0441\u043b\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u043b\u0438 \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 &#8211; \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c.<br \/>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">tensorflow<\/span><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">itertools<\/span><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">random<\/span><span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">time<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> time<span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">ClassifiedNumber<\/span>:__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: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">__init__<\/span>(<span style=\"color: #007020;\">self<\/span>, number):<span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__number <span style=\"color: #333333;\">=<\/span> number<span style=\"color: #008800; font-weight: bold;\">if<\/span> number <span style=\"color: #333333;\">==<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>:<span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span> <span style=\"color: #888888;\"># zero<\/span><span style=\"color: #008800; font-weight: bold;\">elif<\/span> number <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>:<span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span> <span style=\"color: #888888;\"># positive<\/span><span style=\"color: #008800; font-weight: bold;\">elif<\/span> number <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>:<span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__classifiedAs <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">2<\/span> <span style=\"color: #888888;\"># negative<\/span><span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">number<\/span>(<span style=\"color: #007020;\">self<\/span>):<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #007020;\">self<\/span><span style=\"color: #333333;\">.<\/span>__number<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">classifiedAs<\/span>(<span style=\"color: #007020;\">self<\/span>):<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #007020;\">self<\/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> classifiedAs <span style=\"color: #333333;\">==<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>:<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"background-color: #fff0f0;\">\"Zero\"<\/span><span style=\"color: #008800; font-weight: bold;\">elif<\/span> classifiedAs <span style=\"color: #333333;\">==<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>:<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"background-color: #fff0f0;\">\"Positive\"<\/span><span style=\"color: #008800; font-weight: bold;\">elif<\/span> classifiedAs <span style=\"color: #333333;\">==<\/span> <span style=\"color: #0000dd; font-weight: bold;\">2<\/span>:<span style=\"color: #008800; font-weight: bold;\">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;\">for<\/span> i <span style=\"color: #000000; font-weight: bold;\">in<\/span> <span style=\"color: #007020;\">range<\/span>(<span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">1000<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">1001<\/span>):number <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: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">inputDatasetFunction<\/span>():<span style=\"color: #008800; font-weight: bold;\">global<\/span> randomSeedrandom<span style=\"color: #333333;\">.<\/span>seed(randomSeed) <span style=\"color: #888888;\"># to get same result<\/span>numbers <span style=\"color: #333333;\">=<\/span> []<span style=\"color: #008800; font-weight: bold;\">for<\/span> i <span style=\"color: #000000; font-weight: bold;\">in<\/span> <span style=\"color: #007020;\">range<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">4<\/span>):numbers<span style=\"color: #333333;\">.<\/span>append(random<span style=\"color: #333333;\">.<\/span>randint(<span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">9999999<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">9999999<\/span>))<span style=\"color: #008800; font-weight: bold;\">return<\/span> {<span style=\"background-color: #fff0f0;\">\"number\"<\/span> : numbers }<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span>():<span style=\"color: #007020;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"TensorFlow Positive-Negative-Zero numbers classifier test by demensdeum 2017 (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: bold;\">1<\/span>])) <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>numberFeature <span style=\"color: #333333;\">=<\/span> tensorflow<span style=\"color: #333333;\">.<\/span>feature_column<span style=\"color: #333333;\">.<\/span>numeric_column(<span style=\"background-color: #fff0f0;\">\"number\"<\/span>)classifier <span style=\"color: #333333;\">=<\/span> tensorflow<span style=\"color: #333333;\">.<\/span>estimator<span style=\"color: #333333;\">.<\/span>DNNClassifier(feature_columns <span style=\"color: #333333;\">=<\/span> [numberFeature], hidden_units <span style=\"color: #333333;\">=<\/span> [<span style=\"color: #0000dd; font-weight: bold;\">10<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">20<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>], n_classes <span style=\"color: #333333;\">=<\/span> maximalClassesCount)generator <span style=\"color: #333333;\">=<\/span> classifier<span style=\"color: #333333;\">.<\/span>train(input_fn <span style=\"color: #333333;\">=<\/span> trainDatasetFunction, steps <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1000<\/span>)<span style=\"color: #333333;\">.<\/span>predict(input_fn <span style=\"color: #333333;\">=<\/span> inputDatasetFunction)inputDataset <span style=\"color: #333333;\">=<\/span> inputDatasetFunction()results <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">list<\/span>(itertools<span style=\"color: #333333;\">.<\/span>islice(generator, <span style=\"color: #007020;\">len<\/span>(inputDatasetFunction()[<span style=\"background-color: #fff0f0;\">\"number\"<\/span>])))i <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #008800; font-weight: bold;\">for<\/span> result <span style=\"color: #000000; font-weight: bold;\">in<\/span> results:<span style=\"color: #007020;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"number: %d classified as %s\"<\/span> <span style=\"color: #333333;\">%<\/span> (inputDataset[<span style=\"background-color: #fff0f0;\">\"number\"<\/span>][i], classifiedAsString(result[<span style=\"background-color: #fff0f0;\">\"class_ids\"<\/span>][<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>])))i <span style=\"color: #333333;\">+=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>randomSeed <span style=\"color: #333333;\">=<\/span> time()main()<\/pre>\n<\/div>\n<p>\u0412\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 main(), \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e\u0432\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 &#8211; <strong>tensorflow.feature_column.numeric_column(&#8220;number&#8221;)<\/strong> \u0434\u0430\u043b\u0435\u0435 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430. \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a API \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c, \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 TensorFlow, \u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u043c\u0430\u043d\u0443\u0430\u043b\u044b.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 \u0447\u0438\u0441\u0435\u043b \u043e\u0442\u00a0-1000 \u0434\u043e 1000 (<strong>trainDatasetFunction<\/strong>), \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u044d\u0442\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0443 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e, \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043b\u0438\u0431\u043e \u043d\u0443\u043b\u044f. \u0421\u043b\u0435\u0434\u043e\u043c \u043f\u043e\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 \u0447\u0438\u0441\u043b\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 &#8211; \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u043e\u0442 -9999999 \u0434\u043e 9999999 (<strong>inputDatasetFunction<\/strong>) \u0434\u043b\u044f \u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0412 \u0444\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (<strong>itertools.islice<\/strong>) \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0443\u0434\u0438\u0432\u043b\u044f\u0435\u043c\u0441\u044f:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\">number: 4063470 classified as Positivenumber: 6006715 classified as Positivenumber: -5367127 classified as Negativenumber: -7834276 classified as Negative<\/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>\u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u044f \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0434\u0438\u0432\u043b\u0435\u043d \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 *\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442* \u0434\u0430\u0436\u0435 \u0442\u0435 \u0447\u0438\u0441\u043b\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u0435\u0433\u043e \u043d\u0435 \u043e\u0431\u0443\u0447\u0430\u043b. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441 \u0442\u0435\u043c\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0431\u0443\u0434\u0443\u0442 \u0435\u0449\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b.<\/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>\u0421\u0441\u044b\u043b\u043a\u0438:<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>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Deep Learning &#8211; TensorFlow. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0438\u0435, \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438 \u043d\u043e\u043b\u044c. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 TensorFlow \u0438 CUDA \u044f \u043f\u043e\u0440\u0443\u0447\u0430\u044e \u0432\u0430\u043c, \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u0438\u0437 \u043b\u0435\u0433\u043a\u0438\u0445) \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b. TensorFlow \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439<a class=\"more-link\" href=\"https:\/\/demensdeum.com\/blog\/ru\/2017\/12\/06\/simple-example-tensorflow\/\">Continue reading <span class=\"screen-reader-text\">&#8220;\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 TensorFlow&#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":"ru","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\/ru\/wp-json\/wp\/v2\/posts\/1258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/comments?post=1258"}],"version-history":[{"count":26,"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/posts\/1258\/revisions"}],"predecessor-version":[{"id":3988,"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/posts\/1258\/revisions\/3988"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/media?parent=1258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/categories?post=1258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ru\/wp-json\/wp\/v2\/tags?post=1258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}