In TF1, i could use summary_iterator
to read summary files. But now, it will throw a warning
WARNING:tensorflow: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.
Instructions for updating:
Use eager execution and:
`tf.data.TFRecordDataset(path)`
So i'm wondering how to use tf.data.TFRecordDataset(path)
to read tfevent files generated by TF2.
The tf. summary module provides APIs for writing summary data. This data can be visualized in TensorBoard, the visualization toolkit that comes with TensorFlow. See the TensorBoard website for more detailed tutorials about how to use these APIs, or some quick examples below.
Dataset. from_tensor_slices() method, we can get the slices of an array in the form of objects by using tf. data.
The TFRecord format is a simple format for storing a sequence of binary records. Protocol buffers are a cross-platform, cross-language library for efficient serialization of structured data. Protocol messages are defined by . proto files, these are often the easiest way to understand a message type.
Actually, this works for me
from tensorflow.core.util import event_pb2
serialized_examples = tf.data.TFRecordDataset(path)
for serialized_example in serialized_examples:
event = event_pb2.Event.FromString(serialized_example.numpy())
for value in event.summary.value:
t = tf.make_ndarray(value.tensor)
print(value.tag, event.step, t, type(t))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With