- Mastering TensorFlow 1.x
- Armando Fandango
- 248字
- 2021-06-25 22:50:58
A TensorBoard minimal example
- Start by defining the variables and placeholders for our linear model:
# Assume Linear Model y = w * x + b
# Define model parameters
w = tf.Variable([.3], name='w',dtype=tf.float32)
b = tf.Variable([-.3], name='b', dtype=tf.float32)
# Define model input and output
x = tf.placeholder(name='x',dtype=tf.float32)
y = w * x + b
- Initialize a session, and within the context of this session, do the following steps:
- Initialize global variables
- Create tf.summary.FileWriter that would create the output in the tflogs folder with the events from the default graph
- Fetch the value of node y, effectively executing our linear model
with tf.Session() as tfs:
tfs.run(tf.global_variables_initializer())
writer=tf.summary.FileWriter('tflogs',tfs.graph)
print('run(y,{x:3}) : ', tfs.run(y,feed_dict={x:3}))
- We see the following output:
run(y,{x:3}) : [ 0.60000002]
As the program executes, the logs are collected in the tflogs folder that would be used by TensorBoard for visualization. Open the command line interface, navigate to the folder from where you were running the ch-01_TensorFlow_101 notebook, and execute the following command:
tensorboard --logdir='tflogs'
You would see an output similar to this:
Starting TensorBoard b'47' at http://0.0.0.0:6006
Open a browser and navigate to http://0.0.0.0:6006. Once you see the TensorBoard dashboard, don't worry about any errors or warnings shown and just click on the GRAPHS tab at the top. You will see the following screen:
TensorBoard console
You can see that TensorBoard has visualized our first simple model as a computation graph:
Computation graph in TensorBoard
Let's now try to understand how TensorBoard works in detail.
推薦閱讀
- 零點起飛學(xué)Xilinx FPG
- Intel FPGA/CPLD設(shè)計(基礎(chǔ)篇)
- 用“芯”探核:龍芯派開發(fā)實戰(zhàn)
- 顯卡維修知識精解
- 電腦軟硬件維修大全(實例精華版)
- 極簡Spring Cloud實戰(zhàn)
- 施耐德SoMachine控制器應(yīng)用及編程指南
- Getting Started with Qt 5
- 電腦常見故障現(xiàn)場處理
- 硬件產(chǎn)品經(jīng)理成長手記(全彩)
- Hands-On Machine Learning with C#
- CC2530單片機技術(shù)與應(yīng)用
- Building Machine Learning Systems with Python
- 可編程邏輯器件項目開發(fā)設(shè)計
- 計算機應(yīng)用基礎(chǔ)案例教程(Windows 7+Office 2010)