I have met an error message when I tried to concatenate outcomes from two layers.
def cnn_model_fn(learning_rate):
"""Model function for CNN."""
model1=Sequential()
# Convolutional Layer #1
model1.add(tf.keras.layers.Conv2D(
filters=20,
kernel_size=[10, 1],
kernel_initializer='he_uniform',
bias_initializer=keras.initializers.Constant(value=0),
padding="same",
activation=tf.nn.relu, input_shape=(410,1,3)))
model1.add(Flatten())
model2=Sequential()
model2.add(tf.keras.layers.Conv2D(
filters=20,
kernel_size=[10, 1],
kernel_initializer='he_uniform',
bias_initializer=keras.initializers.Constant(value=0),
padding="same",
activation=tf.nn.relu, input_shape=(410,1,3)))
model2.add(Flatten())
model4=Sequential()
model4.add(keras.layers.Concatenate(axis=-1)([model1, model2]))
optimizer = tf.train.AdamOptimizer(learning_rate)
model4.compile(loss='mean_squared_error',
optimizer=optimizer,
metrics=['mean_absolute_error', 'mean_squared_error'])
return model4
model4=cnn_model_fn(0.1)
model4.summary()
"/usr/local/lib/python3.6/site-packages/tensorflow/python/keras/layers/merge.py in build(self, input_shape) 377 # Used purely for shape validation. 378 if not isinstance(input_shape, list) or len(input_shape) < 2: --> 379 raise ValueError('A
Concatenate
layer should be called ' 380 'on a list of at least 2 inputs') 381 if all([shape is None for shape in input_shape]):ValueError: A
Concatenate
layer should be called on a list of at least 2 inputs"