{"id":10100,"date":"2018-01-17T00:12:10","date_gmt":"2018-01-17T05:12:10","guid":{"rendered":"httpss:\/\/www.powenko.com\/wordpress\/?p=10100"},"modified":"2018-01-17T00:14:07","modified_gmt":"2018-01-17T05:14:07","slug":"04-constant-%e5%b8%b8%e6%95%b8","status":"publish","type":"post","link":"https:\/\/www.powenko.com\/wordpress\/?p=10100","title":{"rendered":"04  Constant \u5e38\u6578"},"content":{"rendered":"<p class=\"western\"><span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u8a08\u7b97\u5716\u662f\u6392\u5217\u6210\u7bc0\u9ede\u5716\u7684\u4e00\u7cfb\u5217<\/span><\/span>TensorFlow<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u64cd\u4f5c\u3002\u6211\u5011\u4f86\u69cb\u5efa\u4e00\u500b\u7c21\u55ae\u7684\u8a08\u7b97\u5716\u3002\u6bcf\u500b\u7bc0\u9ede\u5c07\u96f6\u500b\u6216\u591a\u500b\u5f35\u91cf\u4f5c\u70ba\u8f38\u5165\uff0c\u4e26\u7522\u751f\u5f35\u91cf\u4f5c\u70ba\u8f38\u51fa\u3002\u4e00\u7a2e\u985e\u578b\u7684\u7bc0\u9ede\u662f\u4e00\u500b\u5e38\u91cf\u3002\u50cf\u6240\u6709\u7684<\/span><\/span>TensorFlow<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u5e38\u91cf\u4e00\u6a23\uff0c\u5b83\u4e0d\u9700\u8981\u8f38\u5165\uff0c\u800c\u662f\u8f38\u51fa\u4e00\u500b\u5167\u90e8\u5b58\u5132\u7684\u503c\u3002\u6211\u5011\u53ef\u4ee5\u5275\u5efa\u5169\u500b\u6d6e\u9ede<\/span><\/span>Tensors<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u5f35\u91cf<\/span><\/span>node1<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u548c<\/span><\/span>node2<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/span><\/span><\/p>\n<p class=\"western\"><span style=\"font-family: Calibri, Calibri, sans-serif;\"><span style=\"font-size: medium;\"><span lang=\"zh-CN\">\u7bc4\u4f8b\u7a0b\u5f0f<\/span><\/span><\/span><span style=\"font-family: Calibri, Calibri, sans-serif;\"><span style=\"font-size: medium;\">01_constant.py<\/span><\/span><\/p>\n<ol>\n<li>import tensorflow as tf # <span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u532f\u5165<\/span><\/span>tensorFlow <span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u51fd\u793a\u5eab<\/span><\/span><\/li>\n<li>node1 = tf.constant<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\uff08<\/span><\/span>3.0<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\uff0c<\/span><\/span>dtype = tf.float32<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\uff09 <\/span><\/span># <span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u8a2d\u5b9a\u8b8a\u6578<\/span><\/span>node1 <span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u7684\u8cc7\u6599\u70ba<\/span><\/span>3.0<\/li>\n<li>node2 = tf.constant<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\uff08<\/span><\/span>4.0<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\uff09 <\/span><\/span># <span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u7cfb\u7d71\u5167\u5b9a\u70ba<\/span><\/span>tf.float32<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u7684\u8cc7\u6599\u578b\u614b<\/span><\/span><\/li>\n<li>print(node1) # <span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u5370\u51fa\u8a72\u8cc7\u6599\u578b\u614b<\/span><\/span><\/li>\n<li>print(node1, node2) # <span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u5370\u51fa\u8a72\u8cc7\u6599\u578b\u614b<\/span><\/span><\/li>\n<\/ol>\n<p class=\"western\"><a href=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-10101\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-570x38.png\" alt=\"\" width=\"570\" height=\"38\" srcset=\"https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-570x38.png 570w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-300x20.png 300w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-768x51.png 768w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-316x21.png 316w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-120x8.png 120w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-210x14.png 210w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-496x33.png 496w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1-140x9.png 140w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2018\/01\/1.png 780w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><\/p>\n<p class=\"western\"><span style=\"font-family: Calibri, Calibri, sans-serif;\"><span style=\"font-size: medium;\"><span lang=\"zh-CN\">\u5716<\/span><\/span><\/span><span style=\"font-family: Calibri, Calibri, sans-serif;\"><span style=\"font-size: medium;\">1 <\/span><\/span><span style=\"font-family: Calibri, Calibri, sans-serif;\"><span style=\"font-size: medium;\"><span lang=\"zh-CN\">\u8f38\u51fa\u7d50\u679c<\/span><\/span><\/span><\/p>\n<p class=\"western\"><span style=\"font-family: Calibri, Calibri, sans-serif;\"><span style=\"font-size: medium;\"><span lang=\"zh-CN\">\u57f7\u884c\u7d50\u679c\u6703\u5370\u51fa\u3002<\/span><\/span><\/span><\/p>\n<p>Tensor(&#8220;Const:0&#8221;, shape=(), dtype=float32)<\/p>\n<p>Tensor(&#8220;Const:0&#8221;, shape=(), dtype=float32) Tensor(&#8220;Const_1:0&#8221;, shape=(), dtype=float32)<\/p>\n<p class=\"western\">TensorFlow<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u5728\u6307\u5b9a\u8b8a\u6578\u503c\u6642\uff0c\u4e0d\u6703\u50cf\u4e00\u822c\u8b8a\u6578\u6703\u76f4\u63a5\u5370\u6578<\/span><\/span>3.0<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u548c<\/span><\/span>4.0<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u3002<\/span><\/span><\/p>\n<p class=\"western\"><span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u800c\u662f\u7522\u751f<\/span><\/span>3.0<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u548c<\/span><\/span>4.0<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u7684\u7bc0\u9ede\uff0c\u518d\u900f\u904e<\/span><\/span><strong>session<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u7684\u65b9\u6cd5\uff0c\u5728<\/span><\/span><\/strong>TensorFlow<span style=\"font-family: \u5b8b\u4f53, SimSun;\"><span lang=\"zh-CN\">\u904b\u884c\u6642\u7684\u63a7\u5236\u548c\u72c0\u614b\u3002<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8a08\u7b97\u5716\u662f\u6392\u5217\u6210\u7bc0\u9ede\u5716\u7684\u4e00\u7cfb\u5217TensorFlow\u64cd\u4f5c\u3002\u6211\u5011\u4f86\u69cb\u5efa\u4e00\u500b\u7c21\u55ae\u7684\u8a08\u7b97\u5716\u3002\u6bcf\u500b\u7bc0\u9ede\u5c07\u96f6\u500b\u6216\u591a\u500b\u5f35\u91cf\u4f5c\u70ba [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10101,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[360],"tags":[],"class_list":["post-10100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ch02-"],"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/10100"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10100"}],"version-history":[{"count":1,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/10100\/revisions"}],"predecessor-version":[{"id":10102,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/10100\/revisions\/10102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/10101"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}