Using tf.train.Feature and tf.train.Example with ragged tensors

Viewed 63

How can we use tf.train.Feature and tf.train.Example to save Ragged Tensors to TFRecords?

I have this piece of code:

d = [[], [1, 3], [5]]
d_tf = tf.ragged.constant(d)

How can I write it to TFRecords along with other regular tensors?

Normally I do something like:

feature = {"feat_name": tf.train.Feature(int64_list=tf.train.Int64List(value=feat_val))}
examples = tf.train.Example(features=tf.train.Features(feature=feature))
examples.SerializeToString()

Thanks

0 Answers
Related