I am trying to perform Conv1D on multiple inputs in my model. So I have 15 inputs of size 1x1500 each, where each one is an input to a series of layers. So I have 15 convolutional models which I want to merge before Fully Connected Layer. I have defined the convolutional model in a function, but I cannot understand how to call the function and then merge them.
def defineModel(nkernels, nstrides, dropout, input_shape):
model = Sequential()
model.add(Conv1D(nkernels, nstrides, activation='relu', input_shape=input_shape))
model.add(Conv1D(nkernels*2, nstrides, activation='relu'))
model.add(BatchNormalization())
model.add(MaxPooling1D(nstrides))
model.add(Dropout(dropout))
return model
models = {}
for i in range(15):
models[i] = defineModel(64,2,0.75,(64,1))
I have successfully concatenated 4 models as follows:
merged = Concatenate()([ model1.output, model2.output, model3.output, model4.output])
merged = Dense(512, activation='relu')(merged)
merged = Dropout(0.75)(merged)
merged = Dense(1024, activation='relu')(merged)
merged = Dropout(0.75)(merged)
merged = Dense(40, activation='softmax')(merged)
model = Model(inputs=[model1.input, model2.input, model3.input, model4.input], outputs=merged)
How do I do it for 15 layers in the for loop as writing 15 layers separately isn't efficient?