TF 2.3 Concatenate error – AttributeError: 'Sequential' object has no attribute '_nested_outputs'

Question:

fusion_model = tf.keras.layers.concatenate([m1.output, m2.output])

m1 and m2 are Model objects.

I’m concatenating the outputs of the two models and I’m getting the following error:

AttributeError: ‘Sequential’ object has no attribute ‘_nested_outputs’

This exact code used to work in TF 1.14. Any help? thanks

After experimenting with this example, it appears to crash on the statement m2.output (m1.output runs fine)

my M2 model is:

Layer (type)                 Output Shape              Param #   
=================================================================
rescaling_1 (Rescaling)      (None, 456, 456, 3)       0         
_________________________________________________________________
efficientnetb5 (Functional)  (None, 15, 15, 2048)      28513527  
_________________________________________________________________
global_average_pooling2d (Gl (None, 2048)              0         
_________________________________________________________________
dense_3 (Dense)              (None, 160)               327840    
_________________________________________________________________
dropout_19 (Dropout)         (None, 160)               0         
_________________________________________________________________
predictions (Dense)          (None, 19)                3059      

Answers:

You need to build() the model with the appropriate input_shape parameter. This is what’s causing this issue.

Answered By: Christo S. Christov

I had this error and was able to solved it by adding a tf.keras.layers.InputLayer at the beginning of my model.

https://www.tensorflow.org/api_docs/python/tf/keras/layers/InputLayer

Answered By: Mohammed Alali
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.