在 TensorFlow 中可视化预训练网络的特征

Visualizing the features of a pretrained network in TensorFlow

对于医疗应用,我正在使用 TensorFlow.

重新训练预训练的 Inception-v3 网络

这个网络有最后一层:

pool_3:0 (2048 features)

使用 TF classify_image,我找出了这些特征中的哪些对于每个样本最重要。所以有一个数组,其中包含前 N 个特征的索引,按权重排序。

下一步是可视化特征向量以更好地理解结果。

我该怎么做? TensorBoard 有这个能力吗? 我有点不知所措。任何 suggestion/help 表示赞赏!

也许只打印 N 个有趣的组件会对您有所帮助?

您可以通过以下方式获得 pool_3 向量:

graph = ...   # the session graph (sess.graph) containing Inception model
features = graph.get_tensor_by_name('inception_v3/pool3:0')  # I don't know the exact name, find it in TensorBoard
features_values = sess.run(features)
print features_values[top_N_indices]

如果要用TensorBoard,只能plot:

  • 标量特征(标量摘要):您可以使用 tf.gather(features, [indice])
  • 独立绘制每个特征
  • 激活直方图:我认为这不是很有用,但你可以试试
  • images:你也许可以构造一个图像来绘制包含有趣的特征?那会有点复杂,你可以看, related to this issue and this tutorial