我试图构建一个级联或级联(实际上不知道这是否是正确的定义)的模型集。为了简单起见,我的基本模型如下所示。
----Input----
|
L1-1
|
L1-2
|
Dense
|
Softmax我让其中7位模特接受了交叉验证的训练,并试图以一种层叠的方式将他们包装起来,比如:
-----------------------Input---------------------
| | | | | | |
L1-1 L1-2 L1-3 L1-4 L1-5 L1-6 L1-7
| | | | | | |
L2-1 L2-2 L2-3 L2-4 L2-5 L2-6 L2-7
| | | | | | |
|_______|_______|_______|_______|_______|_______|
| Concatenated |
|___________________Dense Layer_________________|
|
SoftMax每个致密层都有512神经元,所以最终级联的致密层会有总共的7*512=3584神经元。
我所做的是:
models[]的列表中。然后我尝试将它们连接起来,但得到了错误:
Layer merge was called with an input that isn't a symbolic tensor. 在形成级联之后,我要做的是冻结除Concatenated Dense Layer之外的所有中间层,并稍微调整一下。但我被困在所有细节中解释了。
发布于 2017-12-05 15:16:44
为此您需要使用functional模型。这种模型适用于张量。
首先,定义一个公共输入张量:
inputTensor = Input(inputShape)然后,使用此输入调用每个模型以获得输出张量:
outputTensors = [m(inputTensor) for m in models]然后将这些张量传递给级联层:
output = Concatenate()(outputTensors)
output = Dense(...)(output)
#you might want to use an Average layer instead of these two....
output = Activation('softmax')(output)最后,定义从起始张量到结束张量的完整模型:
fullModel = Model(inputTensor,output)https://stackoverflow.com/questions/47653253
复制相似问题