'How to save model.summary() to file in Keras?

There is model.summary() method in Keras. It prints table to stdout. Is it possible to save this to file?



Solution 1:[1]

Here you have another option:

with open('modelsummary.txt', 'w') as f:

    model.summary(print_fn=lambda x: f.write(x + '\n'))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sparklingdew