#!/usr/bin/env python # coding: utf-8 # In[1]: import warnings warnings.simplefilter(action='ignore') # In[2]: import tensorflow as tf # ### 1. 创建计算图并执行 # In[3]: width = tf.placeholder('int32', name='width') height = tf.placeholder('int32', name='height') area = tf.multiply(width, height, name='area') with tf.Session() as sess: sess.run(tf.global_variables_initializer()) print('area:', sess.run(area, feed_dict={width: 6, height: 8})) # ### 2. 将计算图写入log文件, 用于在 TensorBoard 中查看 # In[4]: tf.summary.merge_all() # 将所有要显示在 TensorBoard 的数据整合 train_writer = tf.summary.FileWriter('log/graph_area', sess.graph)