在用tf處理資料時,一般都會儲存為tfrecord格式的資料,有時候會想檢視該tfrecord格式的資料樣本多少個。那麼如何做呢?
參考如下代碼:
import tensorflow as tf
tf_records_filenames = 'xxx.tfrecords'
c = 0
for record in tf.python_io.tf_record_iterator(fn):
c += 1
print c
最後的輸出c就是tfrecord中的樣本數量