首页 > 解决方案 > Tensorflow图中的未连接序列

问题描述

我的稀疏自动编码器模型主要由 10 个卷积层和 10 个转置卷积层组成。完成训练后,我在 Tensorboard 中得到了如下图。

张量板图

我的理解是这个图没有连接,因为 Conv1 和 Conv2 没有连接。这是我的第一个 TensorFlow 模型,所以我很困惑。请建议我做错了什么。此代码是基于 CIFAR10 多 GPU 代码开发的。

模型片段

def inference(images, labels, keep_prob, batch_size):
  """Build the cnn model.
  Args:
    images: Images returned from distorted_inputs() or inputs().
    keep_prob: Dropout probability
  Returns:
    Logits.
  """

# conv1
  with tf.variable_scope('conv1') as scope:
    kernel1 = _variable_with_weight_decay('weights', shape=[5, 5, model_params.org_image['channels'], 100], stddev=1e-4, wd=0.0)
    conv1 = tf.nn.conv2d(images, kernel1, [1, 1, 1, 1], padding='SAME')
    biases1 = _variable_on_cpu('biases', [100], tf.constant_initializer(0.0))
    bias1 = tf.nn.bias_add(conv1, biases1)
    conv1 = tf.nn.relu(bias1, name=scope.name)
    print(tf.abs(conv1))
    _activation_summary(conv1)

  # norm1
  norm1 = tf.nn.batch_normalization(conv1, mean=0.6151888371, variance=0.2506813109, offset=None, scale=False, variance_epsilon=0.001, name='norm1') 

  # conv2
  with tf.variable_scope('conv2') as scope:
    kernel2 = _variable_with_weight_decay('weights', shape=[5, 5, 100, 120], stddev=1e-4, wd=0.0)
    conv2 = tf.nn.conv2d(norm1, kernel2, [1, 1, 1, 1], padding='SAME')
    biases2 = _variable_on_cpu('biases', [120], tf.constant_initializer(0.1))
    bias2 = tf.nn.bias_add(conv2, biases2)
    conv2 = tf.nn.relu(bias2, name=scope.name)
    print(tf.abs(conv2))
    _activation_summary(conv2)

  # norm2
  norm2 = tf.nn.batch_normalization(conv2, mean=0.6151888371, variance=0.2506813109, offset=None, scale=False, variance_epsilon=0.001, name='norm2')
  # pool2

……

即使我不明白为什么“IsVariable”会显示在我的图表中。任何类型的帮助都将受到高度赞赏。

更新

我找到了这个解决方案,上面写着“多 GPU 图形看起来像这样是因为多 GPU 版本中的命名空间创建了 tower_N 命名空间,这些命名空间的传入边(张量)高于某个阈值,此时我们会在侧面提取这些节点因为通常它们最终是辅助的,而不是主网络架构的一部分。” 不过,我对我的图表是否完美感到困惑。

标签: pythontensorflowtensorboard

解决方案


我运行了原始的 CIFAR10 多 GPU 代码并检查了与我的图表相似的 CIFAR10 tensorboard 结果。所以我的结论是我的图表很好。

CIFAR10 张量板结果


推荐阅读