Tensorflow - Tensorboard Event Accumulator 从 TensorEvent 获取 Tensor

Tensorflow - Tensorboard Event Accumulator get Tensor from TensorEvent

我正在使用 Tensorflow 和 Tensorboard 1.14 版。 我想使用 tf.summary.tensor_summary()

从训练期间保存的数据开始执行一些离线分析

我无法恢复使用 描述的方法保存的数据,使用 tf.train.summary_iterator 可以恢复标量数据,但不能恢复我使用 tensor_summary 方法保存的数据.

虽然使用 EventAccumulator 对象我能够恢复我保存的数据,它作为具有以下属性的 TensorEvent 对象返回:

  1. 步骤
  2. wall_time
  3. tensor_proto
  4. tensor_content

问题是我想将此数据转换为 numpy 数组,TensorEvent 对象肯定具有所需的所有信息(tensor_proto 用于类型和形状,tensor_content 用于值),但没有作为 Tensor 没有 .value 或 .numpy() 方法。 所以我要将 TensorEvent 对象转换为 numpy 数组? 或者等效地转换为 Tensor 对象然后转换为 numpy 数组?

您可以将 tf.make_ndarray to convert a TensorProto 用于 NumPy 数组:

tensor_np = tf.make_ndarray(tensor_event.tensor_proto)