how to convert numpy to tfrecords and then generate batches?

The whole process is simplied using the Dataset API. Here are both the parts: (1): Convert numpy array to tfrecords and (2): read the tfrecords to generate batches. 1. Creation of tfrecords from a numpy array: Example arrays: inputs = np.random.normal(size=(5, 32, 32, 3)) labels = np.random.randint(0,2,size=(5,)) def npy_to_tfrecords(inputs, labels, filename): with tf.io.TFRecordWriter(filename) as writer: … Read more

Is there a simpler way to handle batch inputs from tfrecords?

The whole process is simplied using the Dataset API. Here are both the parts: (1): Convert numpy array to tfrecords and (2): read the tfrecords to generate batches. 1. Creation of tfrecords from a numpy array: Example arrays: inputs = np.random.normal(size=(5, 32, 32, 3)) labels = np.random.randint(0,2,size=(5,)) def npy_to_tfrecords(inputs, labels, filename): with tf.io.TFRecordWriter(filename) as writer: … Read more