Search code examples
numpytensorflowtensorboard

Tensorflow - Tensorboard Event Accumulator get Tensor from TensorEvent


I am working with Tensorflow and Tensorboard version 1.14. I would like to perform some off-line analysis starting from Data I have saved during training using the tf.summary.tensor_summary()

I am not able to recover the data saved with the method described here, using the tf.train.summary_iterator which does recover scalar data but not the data I saved with the tensor_summary method.

Though with the EventAccumulator object I am able to recover the data I have saved, that it is returned as a TensorEvent Object which has the following attributes:

  1. step
  2. wall_time
  3. tensor_proto
  4. tensor_content

Thing is that I would like to convert this data into numpy array, the TensorEvent object sure has all the information needed (tensor_proto for type and shape, tensor_content for values), but not being a Tensor does not have a .value or a .numpy() method. So I do I trasform a TensorEvent Object into a numpy array? or equivalently into a Tensor object then into a numpy array?


Solution

  • You can use tf.make_ndarray to convert a TensorProto into a NumPy array:

    tensor_np = tf.make_ndarray(tensor_event.tensor_proto)