简体   繁体   English

使用不同输入的集合模型

[英]Ensembling models with different inputs

I instantiated 3 simple not so deep models(could be deeper as I like) and trained them with 3 seperate inputs. 我实例化了3个简单的不那么深的模型(可以更深入我喜欢)并用3个单独的输入训练它们。 To be clear, the first input is the face image, second is eyes and the third is mouth (for facial expression recognition). 要清楚,第一个输入是面部图像,第二个是眼睛,第三个是嘴(用于面部表情识别)。 I'd like to ensemble a model that I feed with 3 inputs (with all same class label ofc) and get a single label output. 我想整合一个模型,我用3个输入(所有相同类标签为c)提供并获得单个标签输出。 The motivation is that 90% accurate models may perform better when ensembled together. 动机是90%准确的模型在组合在一起时可能表现更好。 It should look like this: 它应该如下所示:

Facial input-----------Eyes Input------------Mouth Input
 (100x100x1)          (100x100x1)          (100x100x1) 
     |                     |                     | 

   .....                 ......                .....

     |                     |                     |
      ___________________________________________
                 Some concatenation over here
                           |
                   | Output Label|    

Or should I complete forget this; 或者我应该完全忘记这一点; acquire the response of bottom Dense layers of each model after test, and combine them to a feature vector and classify. 在测试之后获取每个模型的底部Dense层的响应,并将它们组合成特征向量并进行分类。 Clueless over here... 在这里无能为力......

Suppose your models are called model1 , model2 and model3 . 假设你的模型称为model1model2model3 You can use the functional API to merge your models like this: 您可以使用功能API来合并模型,如下所示:

input1 = model1.input
input2 = model2.input
input3 = model3.input

m1 = model1(input1)
m2 = model2(input2)
m3 = model3(input3)

output = concatenate([m1, m2, m3]) # this is the concatenation
output = Dense(10)(output) # just an example for what you could add to the model
output = Activation('softmax')(output)

model = Model(inputs=[input1,input2,input3], outputs=output)

model can then be trained and it will train all three models simultaniously. 然后可以训练model ,它将同时训练所有三个模型。 If you only want to train the part of the model on top of the three models, you can use the trainable parameter. 如果您只想在三个模型之上训练模型的一部分,则可以使用trainable参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM