I am new to Deep Learning and have been trying to show a plot of the CNN architecture using Python in Google Colab. Besides importing the necessary libraries, I have noticed from other resource that normally, we would declare a model {model = sequential()}, and then model.add (Conv2d or MaxPool or Activation etc.) and for visualising, print(model.summary()).

However, I have developed the CNN architecture using the below code and struggling with generating a model print. Could anybody tell what I am missing here. Thanks

input = Input(shape=X.shape[1:])                                  # 154x154x3
x = Conv2D(12, (3, 3), padding='same', activation='relu')(input)  # 154x154x12
x = Conv2D(12, (2, 2), strides=(2, 2), activation='relu')(x)      # 77x77x12
x = Conv2D(16, (3, 3), padding='same', activation='relu')(x)      # 77x77x16
x = Conv2D(16, (2, 2), strides=(2, 2), activation='relu')(x)      # 38x38x16
x = Conv2D(24, (3, 3), padding='same', activation='relu')(x)      # 38x38x24
x = Conv2D(24, (2, 2), strides=(2, 2), activation='relu')(x)      # 19x19x24
x = Conv2D(32, (3, 3), padding='same', activation='relu')(x)      # 19x19x32
x = Conv2D(32, (2, 2), strides=(2, 2), activation='relu')(x)      # 9x9x32
x = Conv2D(48, (3, 3), padding='same', activation='relu')(x)      # 9x9x48
x = Conv2D(48, (2, 2), strides=(2, 2), activation='relu')(x)      # 4x4x48
x = Dropout(0.5)(x)                                               # 4x4x48
x = Conv2D(n_classes, (1, 1))(x)                                  # 4x4x62
x = GlobalAvgPool2D()(x)                                          # 62
output = Activation('softmax')(x)                                 # 62
  • $\begingroup$ Hi nbro, Thank you so much for attending to this question. I am an undergraduate student and did not realise that StackOverflow had blocked me from asking questions for six months. I have always respected the ethos and think 10 times before posting questions, but that's where I am. I though, AI would be the right place to ask these questions. Thank you so much for trying to paste it in stack overflow but I don't think, I can post any question there for at least another 4 months. Thank you so much again. Emanuel $\endgroup$
    – Emanuel
    Mar 12, 2020 at 14:28

1 Answer 1


Add this two lines below of your code.

from keras.models import Model
model = Model(inputs=input, outputs=output) 
  • $\begingroup$ Small spelling error, it should be model.summary instead of model.summery. $\endgroup$
    – Oxbowerce
    Mar 12, 2020 at 19:48
  • $\begingroup$ Hi Ta_Req, Thank you for your input. I was able to find this solution somehow but your contribution helped me gain confidence in what I did. I voted your comment up but apparently, I don't have enough reputations yet to successfully cast it. Regards $\endgroup$
    – Emanuel
    Mar 14, 2020 at 1:13
  • $\begingroup$ Thank you. Glad that you solved your problem. $\endgroup$
    – Ta_Req
    Mar 14, 2020 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.