with tf.io.TFRecordDataset(input_file) as dataset: serialized_dataset = dataset.map(lambda x: x.numpy()) return serialized_dataset 加载数据集并进行预处理 def preprocess_dataset(serialized_dataset): 将图像转换为张量 images = [tf.io.parse_single_example(x, record_features=[])['image'] for ...