【发布时间】:2020-12-13 12:15:13
【问题描述】:
我正在使用 Tflite。我正在学习如何量化为 INT8。
我正在使用 Colab 教程。
“flowers_dir”是一个包含 5 个文件夹的文件夹(每个文件夹包含不同类型的花)。
'/*/*' 是什么意思?我的直觉告诉我这是调用每个文件夹的内容。不确定。有没有类似解释它的“教程”?
# A generator that provides a representative dataset
def representative_data_gen():
dataset_list = tf.data.Dataset.list_files(flowers_dir + '/*/*')
for i in range(100):
image = next(iter(dataset_list))
image = tf.io.read_file(image)
image = tf.io.decode_jpeg(image, channels=3)
image = tf.image.resize(image, [IMAGE_SIZE, IMAGE_SIZE])
image = tf.cast(image / 255., tf.float32)
image = tf.expand_dims(image, 0)
yield [image]
【问题讨论】:
-
文件路径中的通配符
-
flowers_dir中深度为2的子目录下的所有文件
-
顺便说一句——代码应该以文本的形式提供,而不是图像。请参阅Meta Stack Exchange 上的Why not upload images of code/errors when asking a question?。代码图像不可搜索;它们不能被复制/粘贴(这使得重现问题变得不必要地困难);模棱两可的字体无法纠正;屏幕阅读器等辅助工具无法与它们一起使用;对于更高的屏幕分辨率或其他未来的显示技术,它们不是面向未来的;等
标签: python python-3.x tensorflow tensorflow-datasets