Keras model summary

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

Hi Agnes @Agi

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

20210906 Pikairos How to Extract a KERAS Network Summary to a Variable.knwf (161.7 KB)

Hope this helps.

Best

Ael

4 Likes

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

Hi @Agi

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:

The new improved workflow is here below:

20210914 Pikairos How to Extract a KERAS Network Summary to a Variable.knwf (121.1 KB)

Hope this helps.

Best,

Ael

3 Likes

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).

3 Likes

Thanks, I tested, works really nice!

2 Likes

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

3 Likes

Hi @Agi

Thanks for your feedback and for validating the solution :smiley: !

Good luck with your Keras project :blush: !

Ael

2 Likes

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