【发布时间】:2018-06-26 05:16:35
【问题描述】:
目前我正在一次将所有图像提供给 predict_generator。 我希望能够提供一小部分存储在 validation_generator 中的图像并对它们进行预测,这样大型数据集就不会出现内存问题。我应该如何更改以下代码?
top_model_weights_path = '/home/rehan/ethnicity.071217.23-0.28.hdf5'
path = "/home/rehan/countries/pakistan/guys/"
img_width, img_height = 139, 139
confidence = 0.8
model = applications.InceptionResNetV2(include_top=False, weights='imagenet',
input_shape=(img_width, img_height, 3))
print("base pretrained model loaded")
validation_generator = ImageDataGenerator(rescale=1./255).flow_from_directory(path, target_size=(img_width, img_height),
batch_size=32,shuffle=False)
print("validation_generator")
features = model.predict_generator(validation_generator,steps=10)
【问题讨论】:
-
这段代码有什么问题?
-
它在一个实例中使用了所有完整的“验证生成器”,这会导致内存问题。答案显示了它是如何解决的。
标签: tensorflow machine-learning keras imagenet