名称范围和节点

典型的Tensorflow图可能具有数千个节点,为了简化,可以对变量名称设定范围。默认情况下,仅显示节点层次结构的顶层。

下面使用tf.name_scope 在hidden名称范围定义3个指令

import tensorflow as tf

with tf.name_scope('hidden') as scope:
  a = tf.constant(5, name='alpha')
  W = tf.Variable(tf.random_uniform([1, 2], -1.0, 1.0), name='weights')
  b = tf.Variable(tf.zeros([1]), name='biases')

此时会出现3个op名称:

  • hidden/alpha

  • hidden/weights

  • hdden/biases

默认,直观展示工具会将上面3个名字收到名为hidden的节点,但详细信息不会丢失。

【参考】

1。tensorflow-->编程人员指南--->TensorBoard--->图:https://www.tensorflow.org/programmers\_guide/graph\_viz?hl=zh-cn

results matching ""

    No results matching ""