【发布时间】:2020-09-15 22:28:56
【问题描述】:
我正在使用 VGG19 架构从我的图像中提取特征。这是我的代码:
model = VGG19(include_top=False)
image_paths = glob.glob('train/*/*')
def extract_features(model, path):
img_path = path
img = image.load_img(img_path, target_size=(224,224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
features = model.predict(x)
for path in image_paths:
extract_features(model, path)
我想以 Torch 或 tf.通常,我只会将每个 features 附加到一个列表中并将该列表另存为 csv,但我遇到了将列表输入深度学习模型的问题。如何以正确的格式保存这些数据?
【问题讨论】:
-
如果它们是 numpy:np.save(...)? numpy.org/doc/stable/reference/generated/numpy.save.html 或者为什么不是泡菜?
-
np.save 对保存最终张量很有意义,但我想将每个
features附加到什么数据结构? -
也许你可以在检查点保存模型?
标签: python tensorflow keras deep-learning