{"id":836,"date":"2018-08-25T15:33:49","date_gmt":"2018-08-25T07:33:49","guid":{"rendered":"http:\/\/www.liujh168.com\/?p=836"},"modified":"2020-09-06T21:39:03","modified_gmt":"2020-09-06T13:39:03","slug":"tensorflow_beginner","status":"publish","type":"post","link":"https:\/\/www.liujh168.com\/index.php\/2018\/08\/25\/tensorflow_beginner\/","title":{"rendered":"Tensorflow\u5165\u95e8\uff08\u6d45\u663e\u6613\u61c2\u7684\u4f8b\u5b50\u66f4\u5bb9\u6613\u8c41\u7136\u5f00\u6717\uff09"},"content":{"rendered":"<p>\u8282\u9009\u81ea\u201chttps:\/\/blog.csdn.net\/vagrantabc2017\/article\/details\/77002231\u201d<br \/>\nTensorflow API\u5206\u4e24\u7c7b\uff1a<br \/>\nTensorFlow Core\uff1a\u9002\u5408\u7ec6\u7c92\u5ea6\u7684\u63a7\u5236\u6a21\u578b\u3002<br \/>\n\u9ad8\u5c42API\uff1a\u5982 tf.contrib.learn\uff0c\u662f\u5bf9core\u7684\u5c01\u88c5\uff0c\u66f4\u597d\u7528\u3002\u4f46contrib\u76ee\u524d\u4e0d\u7a33\u5b9a\u3002TensorFlow\u7a0b\u5e8f\u5206\u4e24\u5757\uff1a1\uff09\u6784\u9020\u8ba1\u7b97\u56fe 2\uff09\u8fd0\u884c\u8ba1\u7b97\u56fe<br \/>\n\u8ba1\u7b97\u56fe\u7531\u8282\u70b9\u548c\u8fb9\u7ec4\u6210\uff0c\u7a0b\u5e8f\u4e0d\u4f1a\u523b\u610f\u6784\u9020\u8fb9\u3002<br \/>\n\u8282\u70b9\u5305\u62ec\uff1a\u5e38\u91cf\u8282\u70b9\uff0c\u64cd\u4f5c\u8282\u70b9\uff0c\u5360\u4f4d\u7b26\u8282\u70b9\uff0c\u53d8\u91cf\u8282\u70b9\u7b49\u3002<br \/>\n<!--more-->\u4f8b\uff1a<br \/>\nnode1 = tf.constant(3.0, dtype=tf.float32)<br \/>\nnode2 = tf.constant(4.0) # also tf.float32 implicitly<br \/>\nprint(node1, node2)<br \/>\n\u8f93\u51fa\uff1aTensor(&#8220;Const:0&#8221;, shape=(), dtype=float32) Tensor(&#8220;Const_1:0&#8221;, shape=(), dtype=float32)<br \/>\nConst\u6307\u51fa\u8fd9\u662f\u4e2a\u5e38\u91cf\u8282\u70b9\u3002<br \/>\n\u4f8b\uff1a<br \/>\nnode3 = tf.add(node1, node2)<br \/>\nprint(&#8220;node3: &#8220;, node3)<br \/>\n\u8f93\u51fa\uff1anode3: \u00a0Tensor(&#8220;Add:0&#8221;, shape=(), dtype=float32)<br \/>\nAdd\u6307\u51fa\u8fd9\u662f\u4e00\u4e2a\u64cd\u4f5c\u8282\u70b9\u3002<br \/>\n\u8282\u70b9\u4e0d\u662f\u503c\uff0c\u8282\u70b9\u53ea\u6709\u7ecf\u8fc7\u8ba1\u7b97\u540e\u624d\u80fd\u5f97\u5230\u503c\u3002\u5982\u4f55\u8ba1\u7b97\uff1f\u7528session.run()\u3002<br \/>\n\u4f8b\uff1a<br \/>\nsess = tf.Session()<br \/>\nprint(&#8220;sess.run(node3): &#8220;,sess.run(node3))<br \/>\n\u8f93\u51fa\uff1asess.run(node3): \u00a07.0<br \/>\n\u901a\u5f97session.run()\u53ef\u4ee5\u5f97\u5230\u4efb\u610f\u8282\u70b9\u7684\u8ba1\u7b97\u503c\u3002<br \/>\nTensorBoard\u53ef\u4ee5\u770b\u5230\u8ba1\u7b97\u56fe\uff0c\u5982\u4f55\u4f7f\u7528\u4ee5\u540e\u518d\u8bb2\u3002<br \/>\n\u5360\u4f4d\u7b26\u8f93\u5165\u4e0e\u8fd0\u7b97\u7b26\u91cd\u8f7d\uff1a<br \/>\n\u4f8b\uff1a<br \/>\na = tf.placeholder(tf.float32)<br \/>\nprint(a)<br \/>\n\u8f93\u51fa\uff1aTensor(&#8220;Placeholder:0&#8221;, dtype=float32)<br \/>\n\u53ef\u89c1\uff1aPlaceholder\u662f\u7b2c\u4e09\u7c7b\u8282\u70b9\u3002<br \/>\n\u4f8b\uff1a<br \/>\na = tf.placeholder(tf.float32)<br \/>\nb = tf.placeholder(tf.float32)<br \/>\nadder_node = a + b<br \/>\nprint(adder_node)<br \/>\n\u8f93\u51fa\uff1aTensor(&#8220;add:0&#8221;, dtype=float32)<br \/>\n\u53ef\u89c1\uff1a\u52a0\u53f7\u91cd\u8f7d\u4e86tf.add()\u65b9\u6cd5\uff0c\u4e5f\u662f\u4e00\u4e2a\u64cd\u4f5c\u8282\u70b9\uff0c\u8f93\u51fa\u533a\u522b\u53ea\u6709\u628aAdd\u6362\u6210\u4e86add\u3002<br \/>\n\u4f8b\uff1a<br \/>\nprint(sess.run(a, {a: [1,3]}))<br \/>\nprint(sess.run(adder_node, {a: 3, b:4.5}))<br \/>\nprint(sess.run(adder_node, {a: [1,3], b: [2, 4]}))<br \/>\n\u8f93\u51fa\uff1a<br \/>\n[ 1. \u00a03.]<br \/>\n7.5<br \/>\n[ 3. \u00a07.]<br \/>\n\u5bf9run\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u7684\u89e3\u91ca\uff1a\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662ffeed_dict\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u6620\u5c04\u56fe\u5143\u7d20\u5230\u503c\u3002\u5982{a: 3, b:4.5}\u628a\u56fe\u5143\u7d20a\u6620\u5c04\u5230\u503c3\u3002\u7ecf\u8fc7run()\u8ba1\u7b97\u540e\u7684\u503c\u7684shape\uff0c\u4e0e\u7b2c\u4e00\u4e2a\u53c2\u6570\u76f8\u540c\u3002\u5982a\u88ab\u6620\u5c04\u5230[1,3]\uff0c\u524d\u9762a\u5b9a\u4e49\u4e3afloat32\u7c7b\u578b\uff0c\u7ecf\u8fc7\u8ba1\u7b97\u540e\uff0c\u5f97\u5230[ 1. \u00a03.]\u3002<br \/>\n\u4e58\u6cd5\u4e5f\u88ab\u91cd\u8f7d\uff1a<br \/>\n\u4f8b\uff1a<br \/>\nadd_and_triple = adder_node * 3.<br \/>\nprint(sess.run(add_and_triple, {a: 3, b:4.5}))<br \/>\n\u8f93\u51fa\uff1a22.5<br \/>\nVariable\u662f\u672c\u8282\u9047\u5230\u7684\u7b2c\u56db\u7c7b\u8282\u70b9\u3002<br \/>\n\u4f8b\uff1a<br \/>\nW = tf.Variable([.3], dtype=tf.float32)<br \/>\nprint(W)<br \/>\n\u8f93\u51fa\uff1a&lt;tf.Variable &#8216;Variable:0&#8217; shape=(1,) dtype=float32_ref&gt;<br \/>\n\u5728\u5e94\u7528\u4e2d\uff0cPlaceholder\u7c7b\u578b\u7684\u8282\u70b9\u7528\u4e8e\u8bad\u7ec3\u6570\u636ex\uff0cVariable\u7c7b\u578b\u7684\u8282\u70b9\u7528\u4e8e\u968f\u673a\u53d8\u91cf\u53c2\u6570\u3002<br \/>\n\u4f8b\uff1a\u5b9a\u4e49\u7ebf\u6027\u6a21\u578b\uff1af(x)=0.3x-0.3<br \/>\nW = tf.Variable([.3], dtype=tf.float32)<br \/>\nb = tf.Variable([-.3], dtype=tf.float32)<br \/>\nx = tf.placeholder(tf.float32)<br \/>\nlinear_model = W * x + b<br \/>\n\u8ba8\u8bba\uff1a\u8fd9\u91cc\u7684\u7cfb\u7edf\u548c\u504f\u79fb\u53ea\u662f\u521d\u59cb\u503c\uff0c\u968f\u540e\u53ef\u80fd\u9700\u8981\u8c03\u6574\u3002\u5982\u679c\u7528\u5e38\u91cf\u8282\u70b9\uff0c\u663e\u7136\u4e0d\u5408\u9002\u3002<br \/>\n\u6ce8\u610f\uff1atf.Variable()\u5e76\u4e0d\u521d\u59cb\u5316\u8282\u70b9\uff0cTensorflow\u91c7\u7528\u4e86\u5ef6\u8fdf\u5f0f\u5168\u5c40\u521d\u59cb\u5316\u7684\u7b56\u7565\u3002<br \/>\n\u4f8b\uff1a<br \/>\ninit = tf.global_variables_initializer() #init\u6307\u5411\u521d\u59cb\u5316\u5168\u5c40\u53d8\u91cf\u8282\u70b9\u7684\u5b50\u56fe<br \/>\nsess.run(init) #\u521d\u59cb\u5316\u5168\u5c40\u53d8\u91cf\u8282\u70b9<br \/>\n\u8bc1\u660eTensorflow\u91c7\u7528\u4e86\u5ef6\u8fdf\u5f0f\u5168\u5c40\u521d\u59cb\u5316\u7684\u7b56\u7565\uff1a<br \/>\n\u53cd\u4f8b\uff1a<br \/>\nW = tf.Variable([.3], dtype=tf.float32)<br \/>\nb = tf.Variable([-.3], dtype=tf.float32)<br \/>\nx = tf.placeholder(tf.float32)<br \/>\nlinear_model = W * x + b<br \/>\nprint(sess.run(linear_model, {x:[1,2,3,4]}))<br \/>\n\u8f93\u51fa\uff1a\u629b\u51fa\u5f02\u5e38<br \/>\n\u3002\u3002\u3002\u3002\u3002\u3002tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value Variable_1\u3002\u3002\u3002\u3002\u3002\u3002<br \/>\n\u6b63\u4f8b\uff1a<br \/>\nW = tf.Variable([.3], dtype=tf.float32)<br \/>\nb = tf.Variable([-.3], dtype=tf.float32)<br \/>\nx = tf.placeholder(tf.float32)<br \/>\nlinear_model = W * x + b<br \/>\ninit = tf.global_variables_initializer()<br \/>\nsess.run(init)<br \/>\nprint(sess.run(linear_model, {x:[1,2,3,4]})) \u00a0#f(x)=0.3x-0.3<br \/>\n\u8f93\u51fa\uff1a[ 0. \u00a0 \u00a0 \u00a0 \u00a0 \u00a00.30000001 \u00a00.60000002 \u00a00.90000004]<br \/>\nlinear_model\u5728\u8fd9\u91cc\u63d0\u4f9b\u4e86\u9884\u6d4b\u503c\uff0c\u5373y\u00b7\uff0c\u6211\u4eec\u81ea\u5df1\u63d0\u4f9b\u5b9e\u9645\u503cy\uff0c\u5e76\u5b9a\u4e49\u548c\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u3002<br \/>\n\u7ebf\u6027\u56de\u5f52\u7684\u6807\u51c6\u635f\u5931\u6a21\u578b\uff1a\uff08\u9884\u6d4b\u503c-\u5b9e\u9645\u503c\uff09\u7684\u5e73\u65b9\u548c\u3002\u5b98\u7f51\u6ca1\u7528\u6807\u51c6\u5dee\u3002<br \/>\n\u4f8b\uff1a<br \/>\nW = tf.Variable([.3], dtype=tf.float32)<br \/>\nb = tf.Variable([-.3], dtype=tf.float32)<br \/>\nx = tf.placeholder(tf.float32)<br \/>\ny = tf.placeholder(tf.float32)<br \/>\nlinear_model = W * x + b<br \/>\ninit = tf.global_variables_initializer()<br \/>\nsess.run(init)<br \/>\nsess.run(linear_model, {x:[1,2,3,4]})<br \/>\nsquared_deltas = tf.square(linear_model &#8211; y)<br \/>\nloss = tf.reduce_sum(squared_deltas) ##f(x)=0.3x-0.3<br \/>\nprint(sess.run(loss, {x:[1,2,3,4], y:[0,-1,-2,-3]}))<br \/>\n\u8f93\u51fa\uff1a23.66\uff0c\u8fd9\u5c31\u662f\u5e73\u65b9\u548c\u3002<br \/>\n\u624b\u5de5\u9a8c\u8bc1\uff1a(0-0)\u5e73\u65b9+(0.3+1)\u5e73\u65b9+(0.6+2)\u5e73\u65b9+(0.9+3)\u5e73\u65b9<br \/>\n= 0+ 1.69 + 6.76 + 15.21<br \/>\n= 23.66<br \/>\n\u6a21\u578b\u4e0d\u592a\u597d\uff0c\u504f\u5dee\u592a\u5927\uff0c\u9700\u8981\u8c03\u6574\u53c2\u6570\u503c\u3002<br \/>\n\u4e00\u4e2aVariable\u8282\u70b9\uff0c\u5728\u521d\u59cb\u5316\u4ee5\u540e\uff0c\u53ef\u4ee5\u7528tf.assign()\u4fee\u6539\u503c\uff0c\u8fd9\u6b63\u662fVariable\u8282\u70b9\u7684\u4ef7\u503c\u6240\u5728\u3002<br \/>\n\u4f8b\uff1a\u7ee7\u7eed\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u6a21\u578b\u4fee\u6539\u4e3a\uff1a f(x)=-x+1<br \/>\nsess.run([tf.assign(W, [-1.]), tf.assign(b, [1.])]) #\u8c03\u6574\u53c2\u6570\u503cW=-1,b=1\uff0c\u5e76\u91cd\u65b0\u8ba1\u7b97Variable\u8282\u70b9<br \/>\nprint(sess.run(loss, {x:[1,2,3,4], y:[0,-1,-2,-3]}))<br \/>\n\u8f93\u51fa\uff1a0.0\uff0c\u5b8c\u7f8e\u3002(\u53ef\u60dc\u662f\u4eba\u7ed9\u51fa\u7684\u53c2\u6570\uff0c\u4e0d\u662f\u6a21\u578b\u5b66\u4e60\u5f97\u6765\u7684)<br \/>\n\u5c0f\u7ed3\uff1a\u672c\u7ae0\u7684\u7b2c\u4e00\u6bb5core API\u5c31\u5b66\u5b8c\u4e86\uff0c\u8fd9\u91cc\u6211\u4eec\u4e3b\u8981\u5b66\u4e60\u4e86\u56db\u79cd\u5e38\u89c1\u7684\u8282\u70b9\u7c7b\u578b(\u5e38\u91cf\u8282\u70b9\uff0c\u64cd\u4f5c\u8282\u70b9\uff0c\u5360\u4f4d\u7b26\u8282\u70b9\uff0c\u53d8\u91cf\u8282\u70b9)\u53ca\u5176\u7528\u6cd5\uff0c\u5efa\u7acb\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u3002<br \/>\n\u4e0b\u9762\u7b80\u5355\u8bb2\u8bb2\u5176\u5b83\u7684API\u3002<\/p>\n<p>Tensorflow\u5f53\u524d\u7248\u672c\u4e3a1.2.1\uff0c\u5305\u7ed3\u6784\u5982\u4e0b\uff1a<br \/>\nTensorflow<br \/>\n|&#8212;&#8212;-core \u00a0\u6838\u5fc3\u5305<br \/>\n|&#8212;&#8212;-python python\u63a5\u53e3\u5305<br \/>\n|&#8212;&#8212;-contrib \u76ee\u524d\u8fd8\u5728\u5f00\u53d1\u4e2d\uff0c\u63a5\u53e3\u4e0d\u7a33\u5b9a<br \/>\n|&#8212;&#8212;-examples \u6837\u4f8b<br \/>\n|&#8212;&#8212;-tensorboard \u8ba1\u7b97\u56fe\u770b\u677f<br \/>\n\u7b2c\u4e8c\u6bb5\u4e0b\u9762\u5b66\u4e60\u4e00\u4e2aft.train\u7684API\u3002tf.train API\u7684\u5305\u4f4d\u7f6e\u5728tensorflow.python.training\u4e2d\u3002<br \/>\n\u4f18\u5316\u5668(optimizers)\u7528\u4e8e\u7f13\u6162\u7684\u4fee\u6539\u53d8\u91cf\u7684\u503c\uff0c\u4ee5\u4f7f\u5f97\u635f\u5931\u51fd\u6570\u8fbe\u5230\u6700\u5c0f\u3002<br \/>\n\u6700\u7b80\u5355\u7684\u4f18\u5316\u5668\u662f\u5761\u5ea6\u4e0b\u964d(gradient descent)\u4f18\u5316\u5668\uff0c\u5b83\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u5bf9\u7279\u5b9a\u53d8\u91cf\u7684\u504f\u5bfc\u6765\u4fee\u6539\u53d8\u91cf\u503c\u3002<br \/>\ntf.gradients\u7528\u4e8e\u6c42\u504f\u5bfc\uff0c\u4e3e\u4e2a\u4f8b\u5b50\u3002<br \/>\nf(x,y)=xy\u4e2d\uff0c\u5bf9x\u6c42\u504f\u5bfc\uff0c\u5f88\u660e\u663e\u662fy\u3002\u9a8c\u8bc1\u5982\u4e0b\uff1a<br \/>\nx=tf.Variable([[3,5]])<br \/>\nprint(x) #1&#215;2\u7684\u77e9\u9635<br \/>\ny=tf.Variable([[2],[6]])<br \/>\nprint(y) #2&#215;1\u7684 \u77e9\u9635<br \/>\nfx=tf.matmul(x, y) #\u5f97\u52301&#215;1\u7684\u77e9\u9635<\/p>\n<p>init=tf.global_variables_initializer()<br \/>\nsess.run(init)<br \/>\nprint(sess.run(fx))<br \/>\n\u8f93\u51fa\uff1a<br \/>\n&lt;tf.Variable &#8216;Variable:0&#8217; shape=(1, 2) dtype=int32_ref&gt;<br \/>\n&lt;tf.Variable &#8216;Variable_1:0&#8217; shape=(2, 1) dtype=int32_ref&gt;<br \/>\n[[36]]<br \/>\n\u4e5f\u5c31\u662f\u8bf4\uff0c\u77e9\u9635X\u548cY\u76f8\u4e58\uff0c\u5f97\u5230\u77e9\u9635[[36]]\uff0c\u4ee4\u5b83\u4e3a\u77e9\u9635Z\u3002<br \/>\n\u5982\u679c\u5bf9\u77e9\u9635Z\u6c42X\u7684\u504f\u5bfc\uff0c\u5e94\u8be5\u5f97\u5230Y\u3002<br \/>\nx=tf.Variable([[3,5]])<br \/>\ny=tf.Variable([[2],[6]])<br \/>\nfx=tf.matmul(x, y) #\u5f97\u52301&#215;1\u7684\u77e9\u9635<br \/>\nyy=tf.gradients(fx,[x]) #\u5bf9\u6a21\u578bfx\u6c42\u5bf9x\u7684\u504f\u5bfc\u3002<br \/>\nsess.run(tf.global_variables_initializer())<br \/>\nprint(sess.run(yy))<br \/>\n\u8f93\u51fa\uff1a[array([[2, 6]])]\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u5f97\u5230\u7684yy\u6b63\u662f\u8bbe\u60f3\u7684x\u7684\u504f\u5bfcy.<\/p>\n<p>TensorFlow\u4e2d\u7684GradientDescentOptimizer\u4f18\u5316\u5668\u91c7\u7528\u4e86\u7c7b\u4f3c\u7684\u6c42\u5bfc\u7b97\u6cd5\uff0c\u5e95\u5c42\u7ec6\u8282\u88ab\u5c01\u88c5\u3002<br \/>\n\u5b8c\u6574\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<br \/>\nimport tensorflow as tf<br \/>\nW = tf.Variable([.3], dtype=tf.float32) \u00a0#W\u521d\u503c\u4e3a0.3<br \/>\nb = tf.Variable([-.3], dtype=tf.float32) #b\u521d\u503c\u4e3a-0.3<br \/>\nx = tf.placeholder(tf.float32) #x\u7531\u8bad\u7ec3\u6570\u636e\u63d0\u4f9b<br \/>\nlinear_model = W * x + b #\u5efa\u7acb\u6a21\u578b<br \/>\ny = tf.placeholder(tf.float32) #y\u7531\u6807\u6ce8\u6570\u636e\u7ed9\u51fa<br \/>\nloss = tf.reduce_sum(tf.square(linear_model &#8211; y)) # \u635f\u5931\u51fd\u6570\uff0c\u7531\u5e73\u65b9\u548c\u8868\u5f81<br \/>\noptimizer = tf.train.GradientDescentOptimizer(0.01) #\u6700\u7b80\u5355\u7684\u4f18\u5316\u5668\uff0c\u5761\u5ea6\u4e0b\u964d\uff0c\u5b66\u4e60\u7387\u4e3a0.01<br \/>\ntrain = optimizer.minimize(loss) #\u628a\u635f\u5931\u51fd\u6570\u503c\u964d\u5230\u6700\u5c0f<br \/>\nx_train = [1,2,3,4]<br \/>\ny_train = [0,-1,-2,-3] #\u6807\u6ce8\u6570\u636e<br \/>\ninit = tf.global_variables_initializer()<br \/>\nsess = tf.Session()<br \/>\nsess.run(init) #\u521d\u59cb\u5316Variable\u7c7b\u578b\u8282\u70b9<br \/>\nfor i in range(1000): #1000\u6b21<br \/>\nsess.run(train, {x:x_train, y:y_train}) #train\u662f\u201c\u628a\u635f\u5931\u51fd\u6570\u503c\u964d\u5230\u6700\u5c0f\u201d\u7684\u8282\u70b9\uff0c\u628a\u8fd9\u4e2a\u8282\u70b9\u6839\u636e\u8bad\u7ec3\u6837\u672c\u8ba1\u7b971000\u6b21\u3002\u8fd9\u4f1a\u5f71\u54cd\u5230loss\uff0c\u8fdb\u800c\u5f71\u54cd\u5230linear_model\uff0c\u4ece\u800c\u8c03\u6574W\u548cb.<br \/>\ncurr_W, curr_b, curr_loss = sess.run([W, b, loss], {x:x_train, y:y_train}) #\u7ecf\u8fc71000\u6b21\u8bad\u7ec3\uff0c\u62ff\u51fa\u6765\u770b\u770b\u53c2\u6570\u662f\u5426\u5df2\u8db3\u591f\u597d\u3002<br \/>\nprint(&#8220;W: %s b: %s loss: %s&#8221;%(curr_W, curr_b, curr_loss))<br \/>\n\u8f93\u51fa\uff1aW: [-0.9999969] b: [ 0.99999082] loss: 5.69997e-11<br \/>\n\u5728\u7b2c\u4e00\u5c0f\u8282\u4e2d\uff0c\u4eba\u4e3a\u8bbe\u7f6eW=-1,b=1\uff0c\u5f97\u5230\u5b8c\u7f8e\u7ed3\u679c\u3002\u73b0\u5728\u65e0\u9700\u8bbe\u7f6e\uff0c\u901a\u8fc7\u5b66\u4e60\uff0c\u6a21\u578b\u5f97\u5230\u4e86\u975e\u5e38\u8fd1\u4f3c\u7684\u7ed3\u679c\u3002<br \/>\n\u770bTensorBoard\u7684\u8bdd\uff0c\u57fa\u672c\u4e0d\u77e5\u6240\u4e91\u3002<br \/>\n\u5c0f\u7ed3\uff1a<br \/>\n1.\u5efa\u7acb\u6a21\u578b;<br \/>\n2.\u5efa\u7acb\u635f\u5931\u51fd\u6570;<br \/>\n3.\u8bbe\u6cd5\u8ba9\u635f\u5931\u51fd\u6570\u6700\u5c0f\u5316\uff0c\u4ee5\u4fbf\u8ba9\u6a21\u578b\u672c\u6b21\u5b66\u4e60\u8fbe\u5230\u6700\u4f18\uff0c\u8fbe\u5230\u5c40\u90e8\u6700\u4f18;<br \/>\n4.\u91cd\u590d\u7b2c3\u6b65N\u6b21\uff0c\u8fd9\u662f\u4e00\u4e2a\u6e10\u8fd1\u5b66\u4e60\u7684\u8fc7\u7a0b\uff0c(\u53ef\u80fd)\u8fbe\u5230\u5168\u5c40\u6700\u4f18;<br \/>\n5.\u89c2\u5bdf\u6a21\u578b\u7ed3\u679c\u3002<\/p>\n<p><a id=\"cb_post_title_url\" class=\"postTitle2\" href=\"https:\/\/www.cnblogs.com\/xianhan\/p\/9090426.html\">\u8fd9\u91cc\u7684\u7ebf\u6027\u56de\u5f52\u4e5f\u633a\u61c2\uff1aTensorFlow\u5165\u95e8\uff1a\u7ebf\u6027\u56de\u5f52<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/aymericdamien\/TensorFlow-Examples\/tree\/master\/notebooks\" target=\"_blank\" rel=\"noopener\">TF\u76f8\u5173\u4ee3\u7801<\/a><\/p>\n<p><a href=\"http:\/\/blog.17study.com.cn\/2019\/03\/27\/tensorflow-from-1-to-2-1\/\" target=\"_blank\" rel=\"noopener\">Tensorflow 2.0<\/a>\u6765\u4e86\u3002\u53c8\u8be5\u5b66\u4e60\u4e86\u3002<\/p>\n<p>\u8f6f\u4ef6\u5b89\u88c5\u65f6\u8bbe\u7f6e\u56fd\u5185\u955c\u50cf\u53ef\u52a0\u5feb\u8f6f\u4ef6\u4e0b\u8f7d\u901f\u5ea6<\/p>\n<pre><span class=\"c1\"># \u914d\u7f6e\u6e05\u534ePyPI\u955c\u50cf\uff08\u5982\u65e0\u6cd5\u8fd0\u884c\uff0c\u5c06pip\u7248\u672c\u5347\u7ea7\u5230&gt;=10.0.0\uff09<\/span>\r\n<span class=\"n\">pip<\/span> <span class=\"n\">config<\/span> <span class=\"nb\">set<\/span> <span class=\"k\">global<\/span><span class=\"o\">.<\/span><span class=\"n\">index<\/span><span class=\"o\">-<\/span><span class=\"n\">url<\/span> <span class=\"n\">https<\/span><span class=\"p\">:<\/span><span class=\"o\">\/\/<\/span><span class=\"n\">pypi<\/span><span class=\"o\">.<\/span><span class=\"n\">tuna<\/span><span class=\"o\">.<\/span><span class=\"n\">tsinghua<\/span><span class=\"o\">.<\/span><span class=\"n\">edu<\/span><span class=\"o\">.<\/span><span class=\"n\">cn<\/span><span class=\"o\">\/<\/span><span class=\"n\">simple<\/span><\/pre>\n<pre class=\"highlight\"><code><span class=\"o\">[<\/span>global]\r\n<span class=\"nb\">timeout<\/span> <span class=\"o\">=<\/span> 6000\r\nindex-url <span class=\"o\">=<\/span> https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\r\ntrusted-host <span class=\"o\">=<\/span> pypi.tuna.tsinghua.edu.cn<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8282\u9009\u81ea\u201chttps:\/\/blog.csdn.net\/vagrantabc2017\/article\/detail &hellip; <a href=\"https:\/\/www.liujh168.com\/index.php\/2018\/08\/25\/tensorflow_beginner\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cTensorflow\u5165\u95e8\uff08\u6d45\u663e\u6613\u61c2\u7684\u4f8b\u5b50\u66f4\u5bb9\u6613\u8c41\u7136\u5f00\u6717\uff09\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,4,41],"tags":[31],"class_list":["post-836","post","type-post","status-publish","format-standard","hentry","category-remember","category-education","category-uncategorized","tag-ml"],"_links":{"self":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/posts\/836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/comments?post=836"}],"version-history":[{"count":7,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/posts\/836\/revisions"}],"predecessor-version":[{"id":1152,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/posts\/836\/revisions\/1152"}],"wp:attachment":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/media?parent=836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/categories?post=836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/tags?post=836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}