{"id":294119,"date":"2019-09-01T15:00:19","date_gmt":"2019-09-01T15:00:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=294119"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=294119","title":{"rendered":"\u0423\u0447\u0435\u0431\u043d\u043e\u0435 \u043f\u043e\u0441\u043e\u0431\u0438\u0435 \u043f\u043e TensorFlow: 10 \u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u0435 \u043f\u043e TensorFlow \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 [\u043f\u0435\u0440\u0435\u0432\u043e\u0434]"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \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\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/cv-tricks.com\/artificial-intelligence\/deep-learning\/deep-learning-frameworks\/tensorflow\/tensorflow-tutorial\/\">&quot;TensorFlow Tutorial: 10 minutes Practical TensorFlow lesson for quick learners&quot;<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Ankit Sachan.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e TensorFlow \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 TensorFlow. <\/p>\n<p><a name=\"habracut\"><\/a>   <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d TensorFlow. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e <a href=\"https:\/\/cv-tricks.com\/artificial-intelligence\/deep-learning\/deep-learning-frameworks\/tensorflow\/install-tensorflow-1-0-gpu-ubuntu-14-04-aws-p2-xlarge\/\">\u044d\u0442\u043e\u043c\u0443<\/a> \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443. \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438: \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0441\u0442\u0440\u043e\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"chast-1-osnovy-tensorflow\">\u0427\u0430\u0441\u0442\u044c 1. \u041e\u0441\u043d\u043e\u0432\u044b TensorFlow<\/h2>\n<p>  <\/p>\n<p>TensorFlow \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0433\u0440\u0430\u0444. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 TensorFlow \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b n-\u043c\u0435\u0440\u043d\u044b\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u2014 \u0442\u0435\u043d\u0437\u043e\u0440\u0430\u043c\u0438. \u0413\u0440\u0430\u0444 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432) \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0443\u0437\u043b\u0430\u0445 \u0433\u0440\u0430\u0444\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0431\u0440\u0430 \u0433\u0440\u0430\u0444\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0442\u0435\u043d\u0437\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 &quot;\u043f\u0435\u0440\u0435\u0442\u0435\u043a\u0430\u044e\u0442&quot; \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0430\u0441\u043f\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c TensorFlow \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 TensorFlow \u0432\u0430\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0433\u0440\u0430\u0444\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041f\u043e\u0437\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u043e\u043b\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 python \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 TensorFlow:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">~$\u00a0python Python\u00a02.7.6\u00a0(default,\u00a0Oct\u00a026\u00a02016,\u00a020:30:19)\u00a0 [GCC\u00a04.8.4]\u00a0on\u00a0linux2 Type\u00a0&quot;help&quot;,\u00a0&quot;copyright&quot;,\u00a0&quot;credits&quot;\u00a0or\u00a0&quot;license&quot;\u00a0for\u00a0more\u00a0information. &gt;&gt;&gt; &gt;&gt;&gt;import tensorflow as tf<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u0440\u0430\u0444, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u0435\u0441\u0441\u0438\u0438. \u0413\u0440\u0430\u0444\u044b \u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u0441\u044c \u043a \u0433\u0440\u0430\u0444\u0443 \u043a\u0430\u043a \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0430 \u043a \u0441\u0435\u0441\u0441\u0438\u0438 \u043a\u0430\u043a \u043a \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0435.<\/p>\n<p>  <\/p>\n<h4 id=\"11-grafy-v-tensorflow\">1.1. \u0413\u0440\u0430\u0444\u044b \u0432 TensorFlow<\/h4>\n<p>  <\/p>\n<p>\u0413\u0440\u0430\u0444 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u0430 TensorFlow, \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f (\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438), \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0433\u0440\u0430\u0444\u0435. \u0412\u0441\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0435, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c TensorFlow. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u043e\u043c\u0443 \u0433\u0440\u0430\u0444\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">graph = tf.get_default_graph()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0442\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u044d\u0442\u043e\u043c \u0433\u0440\u0430\u0444\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">graph.get_operations()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u0430\u0448 \u0433\u0440\u0430\u0444 \u043f\u0443\u0441\u0442. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">for op in graph.get_operations():      print(op.name)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0441\u043d\u043e\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u044b\u043c. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0433\u0440\u0430\u0444, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439. <\/p>\n<p>  <\/p>\n<h4 id=\"12-sessii-v-tensorflow\">1.2. \u0421\u0435\u0441\u0441\u0438\u0438 \u0432 TensorFlow<\/h4>\n<p>  <\/p>\n<p>\u0413\u0440\u0430\u0444 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f (\u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442), \u043d\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0433\u0440\u0430\u0444 \u0438\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0433\u0440\u0430\u0444\u0430 \u0432 \u0441\u0435\u0441\u0441\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">sess=tf.Session() ... your code ... ... your code ... sess.close()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u0447\u0430\u0432 \u0441\u0435\u0441\u0441\u0438\u044e \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a <strong>with\u2026 as<\/strong>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">with tf.Session() as sess:     sess.run(f)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043b\u044e\u0441\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e \u0447\u0442\u043e \u0441\u0435\u0441\u0441\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0431\u043b\u043e\u043a\u0430 <strong>with<\/strong><\/p>\n<p>  <\/p>\n<h4 id=\"13-tenzory-v-tensorflow\">1.3. \u0422\u0435\u043d\u0437\u043e\u0440\u044b \u0432 TensorFlow<\/h4>\n<p>  <\/p>\n<p>TensorFlow \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043d\u0437\u043e\u0440\u0430\u0445 \u2014 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u044b numPy. <\/p>\n<p>  <\/p>\n<p>a) <strong>\u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b<\/strong> \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u044b. \u041e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a=tf.constant(1.0)<\/code><\/pre>\n<p>  <\/p>\n<p>\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">print(a) &lt;tf.Tensor'Const:0' shape=() dtype=float32&gt;  print(a) Tensor(&quot;Const:0&quot;, shape=(), dtype=float32)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442 python. \u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0435 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u0435\u0441\u0441\u0438\u044e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0430\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">with tf.Session() as sess:     print(sess.run(a))<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 1.0 <\/p>\n<p>  <\/p>\n<p>b) <strong>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/strong> \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0442\u0435\u043d\u0437\u043e\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0445\u043e\u0434\u0438 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">&gt;&gt;&gt;b = tf.Variable(2.0,name=&quot;test_var&quot;) &gt;&gt;&gt;b &lt;tensorflow.python.ops.variables.Variable object at 0x7f37ebda1990&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 TensorFlow \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043d\u043e TensorFlow \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430 \u0440\u0430\u0437:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">init_op = tf.global_variables_initializer()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">with tf.Session() as sess:     sess.run(init_op)     print(sess.run(b))<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 2.0<br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442\u0435 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435 <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">graph = tf.get_default_graph() for op in graph.get_operations():      print(op.name)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Const test_var\/initial_value test_var test_var\/Assign test_var\/read init<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u00aba\u00bb \u043a\u0430\u043a Const \u0438 \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043a \u0433\u0440\u0430\u0444\u0438\u043a\u0443. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 b \u0432 \u0433\u0440\u0430\u0444 TensorFlow \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u00abtest_var\u00bb, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a test_var\/initial_value, test_var\/read \u0438 \u0442. \u0434. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u0441\u0435\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f TensorBoard, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 TensorFlow \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0441) <strong>\u041f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u044b<\/strong> \u2014 \u044d\u0442\u043e \u0442\u0435\u043d\u0437\u043e\u0440\u044b, \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0432 \u0441\u0435\u0430\u043d\u0441\u0435. \u0422\u043e, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440 \u044d\u0442\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u043e\u0432 \u0438 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a = tf.placeholder(&quot;float&quot;) b = tf.placeholder(&quot;float&quot;) y = tf.multiply(a, b) fd = {a: 2, b: 3} with tf.Session() as sess:     print(sess.run(y, fd))<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 6.0<\/p>\n<p>  <\/p>\n<h4 id=\"14-ustroystva-v-tensorflow\">1.4. \u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 TensorFlow<\/h4>\n<p>  <\/p>\n<p>TensorFlow \u0438\u043c\u0435\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 GPU, CPU \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430\u0445. \u041e\u043d \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0430\u0448 \u043a\u043e\u0434. \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e \u043d\u0435 \u0442\u043e \u043e \u0447\u0435\u043c \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 TF.<br \/>  \u0418\u0442\u0430\u043a \u0432\u043e\u0442 \u043f\u043e\u043b\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 TensorFlow:<br \/>  <img decoding=\"async\" src=\"https:\/\/cv-tricks.com\/wp-content\/uploads\/2017\/02\/Tensorflow_Graph_0.png\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<h2 id=\"chast-2-tutorial-po-tensorflow-s-prostym-primerom\">\u0427\u0430\u0441\u0442\u044c 2. \u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e TensorFlow \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c<\/h2>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438. \u041f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 TensorFlow, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <strong>random_normal<\/strong> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 w \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 784 * 10 \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435\u043c 0,01.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">w=tf.Variable(tf.random_normal([784, 10], stddev=0.01))<\/code><\/pre>\n<p>  <\/p>\n<p><strong>Reduce_mean<\/strong> \u2014 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">b = tf.Variable([10,20,30,40,50,60],name='t') with tf.Session() as sess:     sess.run(tf.initialize_all_variables())     sess.run(tf.reduce_mean(b))<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 35<\/p>\n<p>  <\/p>\n<p><strong>argmax<\/strong> \u2014 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 argmax \u0432 Python. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u0432\u0434\u043e\u043b\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043e\u0441\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a=[ [0.1, 0.2,  0.3  ],     [20,  2,       3   ]     ] b = tf.Variable(a,name='b') with tf.Session() as sess:     sess.run(tf.initialize_all_variables())     sess.run(tf.argmax(b,1))<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u0435\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 ([2, 0]), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a a.<\/p>\n<p>  <\/p>\n<h4 id=\"zadacha-lineynoy-regressii\">\u0417\u0430\u0434\u0430\u0447\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/h4>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438: \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0438\u043c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u044f\u043c\u0443\u044e \u043b\u0438\u043d\u0438\u044e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c 100 \u0442\u043e\u0447\u0435\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043b\u0438\u043d\u0438\u044e.<\/p>\n<p>  <\/p>\n<h4 id=\"21-sozdanie-trenirovochnogo-nabora-dannyh\">2.1. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  <\/p>\n<p>trainX \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 -1 \u0438 1, \u0430 trainY \u2014 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u0432 3 \u0440\u0430\u0437\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 trainX \u043f\u043b\u044e\u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import tensorflow as tf import numpy as np  trainX = np.linspace(-1, 1, 101) trainY = 3 * trainX + np.random.randn(*trainX.shape) * 0.33<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"22-pleysholdery\">2.2. \u041f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u044b<\/h4>\n<p>  <\/p>\n<pre><code class=\"python\">X = tf.placeholder(&quot;float&quot;) Y = tf.placeholder(&quot;float&quot;)<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"23-modelirovanie\">2.3. \u041c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438\u043c\u0435\u0435\u0442 \u0432\u0438\u0434 <\/p>\n<p><math>$$display$$Ymodel = w * x$$display$$<\/math><\/p>\n<p>   \u2014 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 w. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c w \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u043a <\/p>\n<p><math>$$display$$ (Y-y__model)^2$$display$$<\/math><\/p>\n<p>  TensorFlow \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u044b\u0442\u0430\u044f\u0441\u044c \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438. \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f GradientDescentOptimizer, \u0447\u0442\u043e\u0431\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f 0,01. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">w = tf.Variable(0.0, name=&quot;weights&quot;) y_model = tf.multiply(X, w)  cost = (tf.pow(Y-y_model, 2)) train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"24-obuchenie\">2.4. \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  <\/p>\n<p>\u0414\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0433\u0440\u0430\u0444. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e, \u043d\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 TensorFlow \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0433\u0440\u0430\u0444, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0435. \u041f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">init = tf.initialize_all_variables()  with tf.Session() as sess:     sess.run(init)     for i in range(100):         for (x, y) in zip(trainX, trainY):             sess.run(train_op, feed_dict={X: x, Y: y})     print(sess.run(w))<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u2014 \u044d\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0430 <strong>init<\/strong> \u0432\u043d\u0443\u0442\u0440\u0438 <strong>session.run()<\/strong>. \u041f\u043e\u0437\u0436\u0435 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <strong>train_op<\/strong>, \u0441\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u044f \u0435\u0439 <strong>feed_dict<\/strong>. \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 w (\u0441\u043d\u043e\u0432\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 sess.run()), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u043a\u043e\u043b\u043e 3.<\/p>\n<p>  <\/p>\n<h4 id=\"uprazhnenie\">\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435:<\/h4>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c w, \u0447\u0442\u043e \u0432\u044b\u0432\u0435\u0434\u0435\u0442\u0441\u044f?<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">with tf.Session() as sess:     sess.run(init)     print(sess.run(w))<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430, \u0432\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u043b\u0438, \u0432\u044b\u0432\u0435\u0434\u0435\u0442\u0441\u044f 0.0. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u0441\u0435\u0441\u0441\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u043d\u0435\u0435, \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u0434\u0430\u0441\u0442 \u0432\u0430\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u0441 TensorFlow. \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/sankit1\/cv-tricks.com\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/465745\/\"> https:\/\/habr.com\/ru\/post\/465745\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \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\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/cv-tricks.com\/artificial-intelligence\/deep-learning\/deep-learning-frameworks\/tensorflow\/tensorflow-tutorial\/\">&quot;TensorFlow Tutorial: 10 minutes Practical TensorFlow lesson for quick learners&quot;<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Ankit Sachan.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e TensorFlow \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 TensorFlow. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-294119","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294119"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294119\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}