【发布时间】:2021-12-24 22:44:26
【问题描述】:
我正在尝试通过获取每个模型的最后一个隐藏层,然后将它们连接在一起,然后将它们插入元学习器模型(例如 XGBoost)来堆叠我拥有的一些预训练模型。
我遇到了一个大问题,即必须多次处理我的数据集的每个图像,因为每个基本模型都需要不同的处理方法。这导致我的模型需要很长时间才能训练并且不可行。有什么办法可以解决这个问题吗?
例如:
model_1, processor_1 = pretrained_model(), pretrained_processor()
model_2, processor_2 = pretrained_model2(), pretrained_processor2()
for img in images:
input_1 = processor_1(img)
input_2 = processor_2(img)
out_1 = model_1(input_1)
out_2 = model_2(input_2)
torch.cat((out1,out2), dim=1) #concatenates hidden representations to feed into another model
【问题讨论】:
标签: machine-learning image-processing pytorch computer-vision ensemble-learning