I'm struggling with the basics of writing a tensorflow tfrecord file. I'm writing a simple example with an ndarray in python, but for some reason when I read it it's required to be variable-length and reads it as a SparseTensor.
Here's the example
def serialize_tf_record(features, targets): record = { 'shape': tf.train.Int64List(value=features.shape), 'features': tf.train.FloatList(value=features.flatten()), 'targets': tf.train.Int64List(value=targets), } return build_tf_example(record) def deserialize_tf_record(record): tfrecord_format = { 'shape': tf.io.VarLenFeature(tf.int64), 'features': tf.io.VarLenFeature(tf.float32), 'targets': tf.io.VarLenFeature(tf.int64), } features_tensor = tf.io.parse_single_example(record, tfrecord_format) return features_tensor Can anybody explain to me why this writes a variable-length record? It is fixed in code, but I can't seem to write it in a way tensorflow knows its fixed. The tensorflow documentation is pretty horrific here. Can anybody clarify the API for me?