Getting graph disconnected error when trying to build a new model output

I have a trained sequential model which composes of a pre-trained headless efficient net and the final layers. The model.summary() look as follows,

Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
efficientnet-b3 (Model)      (None, 5, 5, 1536)        10783528  
_________________________________________________________________
gap (GlobalMaxPooling2D)     (None, 1536)              0         
_________________________________________________________________
dropout_out (Dropout)        (None, 1536)              0         
_________________________________________________________________
fc_out (Dense)               (None, 1)                 1537      
=================================================================
Total params: 10,785,065
Trainable params: 1,479,937
Non-trainable params: 9,305,128
_________________________________________________________________

I try to build a model which outputs the prediction output and the last convolutional layer output of the efficientnet-b3 model by using,

gradModel = Model(
inputs=[model.inputs],
outputs=[model.layers[0].layers[-3].output, model.output])

But I got the error,

ValueError: Graph disconnected: cannot obtain value for tensor Tensor("input_1:0", shape=(None, 150, 150, 3), dtype=float32) at layer "input_1". The following previous layers were accessed without issue: []

What should I do to solve this issue?

My efficientnet-b3 model looks like,

Model: "efficientnet-b3"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            [(None, 150, 150, 3) 0                                            
__________________________________________________________________________________________________
conv2d (Conv2D)                 (None, 75, 75, 40)   1080        input_1[0][0]                    
__________________________________________________________________________________________________   
.
.
.
__________________________________________________________________________________________________  
add_18 (Add)                    (None, 5, 5, 384)    0           drop_connect_18[0][0]            
                                                                 batch_normalization_73[0][0]     
__________________________________________________________________________________________________
conv2d_103 (Conv2D)             (None, 5, 5, 1536)   589824      add_18[0][0]                     
__________________________________________________________________________________________________
batch_normalization_77 (BatchNo (None, 5, 5, 1536)   6144        conv2d_103[0][0]                 
__________________________________________________________________________________________________
swish_77 (Swish)                (None, 5, 5, 1536)   0           batch_normalization_77[0][0]     
==================================================================================================
Total params: 10,783,528
Trainable params: 1,478,400
Non-trainable params: 9,305,128
__________________________________________________________________________________________________

Go to Source
Author: TinyEpic