tbparse icon indicating copy to clipboard operation
tbparse copied to clipboard

Support parsing tensors without requiring tensorboard

Open Balandat opened this issue 2 years ago • 3 comments

I find it a bit odd that tbparse requires tensorboard in order to parse tensor type logs, even if those are generated e.g. by pytorch. Ideally this could be supported out of the box with just pandas (and hence numpy).

Is there a technical reason for this limitation? I would think that the results could be parsed into pytorch tensors or numpy arrays in the same way?

Balandat avatar Jul 14 '23 03:07 Balandat

tensor events are parsed with TensorFlow with the following code:

https://github.com/j3soon/tbparse/blob/74e89db0e9a088382babef3df0eab3f44120bb82/tbparse/summary_reader.py#L684-L687

The main usage of TensorFlow is for converting TensorProto to a numpy array. We require TensorFlow here since we don't want to manually perform the conversion. To the best of my knowledge, there is no simple alternative instead of tf.make_ndarray.

If you happen to know an alternative way for such a conversion, please let me know. Thanks!

j3soon avatar Jul 17 '23 00:07 j3soon

We do something manually like this here: https://github.com/mshvartsman/Ax/blob/submitit-runner/ax/metrics/tensorboard.py#L112-L123

it's a bit pedestrian but it works. Presumably tf.make_ndarray doesn't do things much smarter? Depending on how it's implemented it may be faster though (haven't checked)

Balandat avatar Jul 17 '23 15:07 Balandat

Thanks! Seems like TensorFlow does something similar (but dealing with more cases):

https://github.com/tensorflow/tensorflow/blob/39f68b781b04014252b01cfb65aabc25448a1ae1/tensorflow/python/framework/tensor_util.py#L630

However, I think we still need to follow the TensorFlow implementation, since the histogram event will log an entire tensor instead of a scalar.

If you have time, I would appreciate it if you could open a PR to fix this. Otherwise, I'll try to fix it myself in the near future.

j3soon avatar Jul 19 '23 05:07 j3soon

Thanks!

Balandat avatar Aug 15 '24 23:08 Balandat

Fixed in v0.0.9 on PyPI.

Sidenote: Related to #10

j3soon avatar Aug 16 '24 04:08 j3soon