Reputation: 46
I am trying to pass and concatenate the output of one layer to another layer in a CNN as shown in the following image. 30x30x512 layer is concatenated with 15x15x1024 after reshaping.
Please note that two different models and merging them is not the solution I am looking for. I am want to know how I can use the same model to merge the mentioned layers.
Thank you in advance for your suggestions.
Upvotes: 3
Views: 529
Reputation: 40516
You need to store the output tensors of both layers you want to merge. Once you have these tensors there are at least two ways to merge them:
Using Reshape
layer where you can specify the output shape and the job is done.
By using tf.space_to_depth
function and packing it to a Lambda
layer (as it's TensorFlow operation). This might be only used when you use TensorFlow backend.
Once you have your output reshaped you can use concatenate
layer and merge outputs by channels dimension.
Upvotes: 3