Tensorflow TFRecord: Can't parse serialized example

tf.FixedLenFeature() is used for reading the fixed size arrays of data. And the shape of the data should be defined beforehand. Updating the parse function to

def parse(tfrecord):
   return tf.parse_single_example(tfrecord, features={
       'label': tf.FixedLenFeature([3], tf.int64, default_value=[0,0,0]),
       'test': tf.FixedLenFeature([3], tf.float32, default_value=[0.0, 0.0, 0.0]),
   })

Should do the job.


As an alternative, if your input features lengths are not fixed and are of arbitrary sizes then you can also use tf.io.FixedLenSequenceFeature() with arguments allow_missing = True and default_value=0 (in case of type int and 0.0 for float) which does not require the input feature to be of fixed size unlike tf.io.FixedLenFeature(). You can find more information here.