# Keras model summary

**URL:** <https://forum.knime.com/t/keras-model-summary/35844>\
**Category:** KNIME Extensions\
**Tags:** deep-learning\
**Created:** [September 6, 2021, 4:47pm UTC](https://forum.knime.com/t/keras-model-summary/35844 "2021-09-06T16:47:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/agi/32/33133_2.png) [@Agi](https://forum.knime.com/u/Agi)\
**Post date:** [September 6, 2021, 4:47pm UTC](https://forum.knime.com/t/keras-model-summary/35844/1 "2021-09-06T16:47:04Z")

</div>

Hi,  
Once I defined a neural net with the KNIME Keras nodes, is there a way to get a sumary of the defined model? If I would implement it in python, I would take the output of the model.summary() function, this is exactly what i’m looking for.

Thanks,  
Agnes

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [September 6, 2021, 4:53pm UTC](https://forum.knime.com/t/keras-model-summary/35844/2 "2021-09-06T16:53:48Z")

</div>

Hi Agnes @Agi

Please find below a workflow that illustrates how to obtain this information from the KERAS summary:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/3/c/3cde74e43f7886d19ff980be7922e9db31917e81.png)

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/8/7/875a2aca453588aed5b86b018720d8f419bb6c9f.png)

[20210906 Pikairos How to Extract a KERAS Network Summary to a Variable.knwf](https://forum.knime.com/uploads/short-url/1bGwUAOek6mbg2v4MYLXCpL02o8.knwf) (161.7 KB)

Hope this helps.

Best

Ael

---

<div class="post-metadata">

**Author:** ![Agi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/agi/32/33133_2.png) [@Agi](https://forum.knime.com/u/Agi)\
**Post date:** [September 7, 2021, 4:23pm UTC](https://forum.knime.com/t/keras-model-summary/35844/3 "2021-09-07T16:23:54Z")

</div>

Hi Ael,

Thank you, I just tested it. If I execute within the DL Python Network Editor, I see the full summary with all layers. However, the variable to table row and the interactive table only show the first few lines. I didn’t see a limit on the size of the variable I could increase. This is a minor problem, it is already enough that I see it in the editor.

All the best,  
Agnes

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [September 14, 2021, 9:19am UTC](https://forum.knime.com/t/keras-model-summary/35844/4 "2021-09-14T09:19:25Z")

</div>

Hi @Agi

> [@Agi](#):
>
> the variable to table row and the interactive table only show the first few lines. I didn’t see a limit on the size of the variable I could increase.

Sorry for my late reply. Indeed you are right. String variables in KNIME seem to be limited in size. I have bypassed the problem by converting the full string into a list of strings in Python. In this case, the KNIME python variable returns the full content of the KERAS summary.

Btw, to generate a “big enough Keras NN” for this example, I have dynamically pilled up 10 layers using a recursive loop. This example may be helpful too to show how to dynamically create a NN with a given number of layers, without having to do it manually.

I have added also a bit of pre-processing that was needed to bring the KERAS summary back to its initial format. KNIME table doesn’t treat tabs in the same way as Python, so the appearance is not exactly the same but if you copy and paste the cell content on an editor, the summary is now correct:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/6/66c5219f841698c02d2758dc8d5caaa8f52ca17a.png)

The new improved workflow is here below:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/5/0/5004c619806f7985a44cfd12a059a62a703a560b.png)

[20210914 Pikairos How to Extract a KERAS Network Summary to a Variable.knwf](https://forum.knime.com/uploads/short-url/iTATdDmNS0H986DJNKnToGtaTO9.knwf) (121.1 KB)

Hope this helps.

Best,

Ael

---

<div class="post-metadata">

**Author:** ![MarcelW](https://forum-cdn.knime.com/user_avatar/forum.knime.com/marcelw/32/352_2.png) [@MarcelW](https://forum.knime.com/u/MarcelW)\
**Post date:** [September 14, 2021, 10:25am UTC](https://forum.knime.com/t/keras-model-summary/35844/5 "2021-09-14T10:25:47Z")

</div>

Just for the sake of completeness: it is also possible to right-click on a node that produces a Keras model and then click “Keras Network” (at the bottom of the context menu). The view that opens shows some of the network’s specifications: names, shapes, data types, etc. (of the network’s tensors instead of its layers though).

---

<div class="post-metadata">

**Author:** ![Agi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/agi/32/33133_2.png) [@Agi](https://forum.knime.com/u/Agi)\
**Post date:** [September 14, 2021, 11:25am UTC](https://forum.knime.com/t/keras-model-summary/35844/6 "2021-09-14T11:25:35Z")

</div>

Thanks, I tested, works really nice!

---

<div class="post-metadata">

**Author:** ![Agi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/agi/32/33133_2.png) [@Agi](https://forum.knime.com/u/Agi)\
**Post date:** [September 14, 2021, 11:26am UTC](https://forum.knime.com/t/keras-model-summary/35844/7 "2021-09-14T11:26:19Z")

</div>

Thanks for the tip Marcel, it is also a useful feature and definitely good to know!

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [September 14, 2021, 11:27am UTC](https://forum.knime.com/t/keras-model-summary/35844/8 "2021-09-14T11:27:02Z")

</div>

Hi @Agi

Thanks for your feedback and for validating the solution 😃 !

Good luck with your Keras project 😊 !

Ael

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [September 21, 2021, 11:27am UTC](https://forum.knime.com/t/keras-model-summary/35844/9 "2021-09-21T11:27:45Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
