I am trying to construct a multi-channel convolutional neural network. I have two tensors (i.e.,
training_x2), each including float values with
(476, 47, 3, 1) dimension. I build the multi-channel NN as follows (a minimal example):
import numpy as np from tensorflow import keras from keras.models import Model from keras.layers import Dense, Conv2D, MaxPooling2D, Flatten, Dropout, concatenate, AveragePooling2D, Input training_x1 = np.zeros((476, 47, 3, 1)) # just as an example training_x2 = np.zeros((476, 47, 3, 1)) # just as an example inputs1 = Input(shape=(training_x1.shape, )) conv1 = Conv2D(filters=32, kernel_size=3, activation='relu')(training_x1) drop1 = Dropout(0.5)(conv1) pool1 = MaxPooling2D(pool_size=2)(drop1) flat1 = Flatten()(pool1) # channel 2 inputs2 = Input(shape=(training_x2.shape, )) conv2 = Conv2D(filters=32, kernel_size=3, activation='relu')(training_x2) drop2 = Dropout(0.5)(conv2) pool2 = MaxPooling2D(pool_size=2)(drop2) flat2 = Flatten()(pool2) # merge merged = concatenate([flat1, flat2]) # interpretation dense1 = Dense(10, activation='relu')(merged) outputs = Dense(1, activation='linear')(dense1) model = Model(inputs=[inputs1, inputs2], outputs=outputs)
However, my model fails with error ValueError: Output tensors of a Functional model must be the output of a TensorFlow Layer (thus holding past layer metadata). What mistake am I making?