def total_sample(file_path):
tfrecords_list = []
temp = os.listdir(file_path)
# Get the path of tfrecord in a dir
sample_nums = 0
for tfrecord in temp:
tfrecords_list.append(os.path.join(file_path, tfrecord))
# print(tfrecords_list[-1])#返回list中的最后一个值
for record in tf.python_io.tf_record_iterator(tfrecords_list[-1]):
sample_nums += 1
# print(sample_nums)
return sample_nums
file_path = r’D:\python-soft\mtan\data\train’
i = total_sample(file_path)