Dear forum,
I have 2 separate CNN:
Each CNN train images and classify 2 classes as output ,lets say:
eg.first CNN X1,Y1
second CNN X2,Y2
I would like to ensemble the two cnn and provide the final classes Z,Y.
I have read some papers and one of them takes the average of two cnn,which seem an acceptable solution.
So even though i have understand the way theoretically(load the weights from the classification of each CNN),i have stuck in the implementation part of how to combine them.Any guidance regarding this mater would be appreciated.
Thank you
What I have tried:
path = "C:\\Users\\Desktop\\"
train_normal_dir = path + 'train/X1/'
train_covid_dir = path + 'train/X2/'
....
....
....
model.add(Conv2D(filters=128, kernel_size=(3,3), padding='same', activation='relu'))
model.add(Conv2D(filters=128, kernel_size=(3,3), padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(1024, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(2, activation='softmax'))
model.summary()
optimizer = Adam(lr=0.0001, decay=1e-5)
model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy'])
history = model.fit(datagen.flow(X_train,y_train, batch_size=4), validation_data=(X_test, y_test), epochs = 20, verbose = 1, class_weight={0:6.0, 1:0.5})
model.save('CNN1.h5')