# Difference between code for model & model summary?

**URL:** <https://discuss.ai.google.dev/t/difference-between-code-for-model-model-summary/11395>\
**Category:** General Discussion\
**Tags:** models\
**Created:** [January 25, 2023, 11:42am UTC](https://discuss.ai.google.dev/t/difference-between-code-for-model-model-summary/11395 "2023-01-25T11:42:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrBwts](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/drbwts/32/11487_2.png) [@DrBwts](https://discuss.ai.google.dev/u/DrBwts)\
**Post date:** [January 25, 2023, 11:42am UTC](https://discuss.ai.google.dev/t/difference-between-code-for-model-model-summary/11395/1 "2023-01-25T11:42:33Z")

</div>

My model:

```auto
class AnomalyDetector(Model):
    def __init__ (self):
        super(AnomalyDetector, self). __init__ ()
        
        self.encoder = tf.keras.Sequential([
            Input(shape=(300, 300, 3)),
            Conv2D(64, (3, 3), activation='relu', padding='same'),
            MaxPooling2D((2, 2), padding='same'),
            BatchNormalization(),
            Conv2D(32, (3, 3), activation='relu', padding='same'),
            MaxPooling2D((2, 2), padding='same'),
            BatchNormalization(),
            Conv2D(16, (3, 3), activation='relu', padding='same'),
            MaxPooling2D((2, 2), padding='same')
            ]) # Smallest Layer Defined Here
    
        self.decoder = tf.keras.Sequential([
            Conv2D(64, (3, 3), activation='relu', padding='same'),
            UpSampling2D((2, 2)),
            Conv2D(32, (3, 3), activation='relu', padding='same'),
            UpSampling2D((2, 2)),
            Conv2D(16, (3, 3), activation='relu'),
            UpSampling2D((2, 2)),
            Conv2D(3, (3, 3), activation='sigmoid', padding='same')
            ])
    
    def call(self, x):
        encoded = self.encoder(x)
        decoded = self.decoder(encoded)
        return decoded

auto_encoder = AnomalyDetector()

```

But when I run,

`print(auto_encoder.summary())`

I get,

```auto
Model: "anomaly_detector"
_________________________________________________________________
 Layer (type) Output Shape Param #   
=================================================================
 sequential (Sequential) (None, 38, 38, 16) 25264     
                                                                 
 sequential_1 (Sequential) (None, 300, 300, 3) 32803     
                                                                 
=================================================================
Total params: 58,067
Trainable params: 57,875
Non-trainable params: 192
_________________________________________________________________
None

```

Am I right in thinking that this is just a summary of the last layer in `self.encoder` and the last layer in `self.decoder`?

Is there a way of getting the full layer list?

---

<div class="post-metadata">

**Author:** ![Kiran\_Sai\_Ramineni](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/kiran_sai_ramineni/32/8859_2.png) [@Kiran\_Sai\_Ramineni](https://discuss.ai.google.dev/u/Kiran_Sai_Ramineni)\
**Post date:** [January 25, 2023, 1:13pm UTC](https://discuss.ai.google.dev/t/difference-between-code-for-model-model-summary/11395/3 "2023-01-25T13:13:46Z")

</div>

Hi @DrBwts, The combined model summary shows the input layer of the first sequential model and the output layer of the second sequential model.If you want to see all layers in the combined model use `model.summary(expand_nested=True)` which will display all the layers of the combined model. Please refer to this [gist](https://gist.github.com/kiransair/bf447740ee1dec5e9f6c3a9524b41680) for working code example. Thank You.
