'show_data')# figure("data")指定图表名称 ax = fig.add_subplot(111) ax.scatter(x_data,y_data) plt.ion() plt.show() xs = tf.placeholder(tf.float32,[None,1]) #外界输入数据 ys = tf.placeholder(tf.float32,[None,1]) l1 = add_layer(xs,1,10,activate=tf.nn.relu) prediction = add_layer(l1,10,1,activate=None) loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),reduction_indices=[1]))#误差 train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)#对误差进行梯度优化,办法为0.1 sess = tf.Session() sess.run( tf.global_variables_initializer()) for i in range(1000): sess.run(train_step, feed_dict={xs: x_data, ys: y_data})#练习 if i%50 == 0: try: ax.lines.remove(lines[0]) except Exception: pass prediction_value = sess.run(prediction, feed_dict={xs: x_data}) lines = ax.plot(x_data,prediction_value,"r",lw = 3) print(sess.run(loss, feed_dict={xs: x_data, ys: y_data}))#查看误差 plt.pause(2) while True: plt.pause(0.01) 
4.TensorBoard整体构造化显示
tensorboard --logdir=test
推荐阅读
教你禁用Windows 10中的各种小广告
比拟之前的Win7/Win8,Win10的告白可谓无孔不入。开端菜单、应用列表、锁屏页面、通知中间……,所有你能想到的处所,几乎都能看到各类告白。
全平易近充电节 | 3月26日~30日 2000位IT行业拭>>>详细阅读
本文标题:TensorFlow学习之神经网络的构建
地址:http://www.17bianji.com/lsqh/40823.html
1/2 1