I have two different types of data (image volumes and coordinates) and I would like to use a convolutional neural network on the image volume data and then after this I would like to append some additional information (ie. the coordinates of the volume).
Independently this should create a pretty solid predictor for my function. How can I implement this using Keras.
The only answers I have found online are either ambiguous or are using the deprecated methods which I have got to work. But I would really like to implement this using the current API that way I can more easily save the model for later use.
model = Sequential() model.add(Conv3D(32, kernel_size=(3, 3, 3), activation='relu', input_shape=input_shape)) model.add(Conv3D(64, (3, 3, 3), activation='relu')) model.add(MaxPooling3D(pool_size=(2, 2, 2))) model.add(Dropout(0.25)) model.add(Flatten()) print(model.output_shape) # The additional data (the coordinates x,y,z) extra = Sequential() extra.add(Activation('sigmoid', input_shape=(3,))) print(extra.output_shape) merged = Concatenate([model, extra]) # New model should encompass the outputs of the convolutional network and the coordinates that have been merged. # But how? new_model = Sequential() new_model.add(Dense(128, activation='relu')) new_model.add(Dropout(0.8)) new_model.add(Dense(32, activation='sigmoid')) new_model.add(Dense(num_classes, activation='softmax')) new_model.compile(loss=keras.losses.categorical_crossentropy, optimizer=keras.optimizers.Adadelta(), metrics=['accuracy'])