I want to build the below architecture of neural network layers
I have a cnn layer:
cnn1 = keras.Sequential([
layers.Input((32, 32, 3)),
layers.Conv2D(32, (5, 5), activation='relu')
]
)
And module:
from tensorflow.keras.layers import Concatenate, Dense
'''Module 1'''
module1_left = keras.Sequential([
layers.Input((28, 28, 32)),
layers.Conv2D(32, (1, 1), activation='relu', padding='same')
]
)
module1_middle = keras.Sequential([
layers.Input((28, 28, 32)),
layers.Conv2D(32, (1, 1), activation='relu', padding='same'),
layers.Conv2D(64, (3, 3), activation='relu', padding='same')
]
)
module1_right = keras.Sequential([
layers.Input((28, 28, 32)),
layers.MaxPooling2D((3, 3), padding='same', strides=(1, 1)),
layers.Conv2D(32, (1, 1), activation='relu', padding='same')
]
)
module1 = keras.layers.concatenate([module1_left.outputs[0], module1_middle.outputs[0], module1_right.outputs[0]], axis=-1)
Then I try to combine cnn1 and module 1, by cnn1.add(module1)
, here's the error for the last line:
TypeError: The added layer must be an instance of class Layer. Found: Tensor("concatenate_27/Identity:0", shape=(None, 28, 28, 128), dtype=float32)
Then I try another approach to concatenate:
module1 = Concatenate([module1_left, module1_middle, module1_right])
Then I get the error:
ValueError: A `Concatenate` layer should be called on a list of at least 2 inputs
Please let me know what's wrong with those approaches. Thank you!
Kind Regards.