0

I have a custom function which plots the results from a neural network, thus: enter image description here

and I want to display the model.summary(), as in

Model: "sequential_35"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense_140 (Dense)            (None, 15)                150       
_________________________________________________________________
dense_141 (Dense)            (None, 15)                240       
_________________________________________________________________
dense_142 (Dense)            (None, 15)                240       
_________________________________________________________________
dense_143 (Dense)            (None, 1)                 16        
=================================================================
Total params: 646
Trainable params: 646
Non-trainable params: 0
_________________________________________________________________

in the upper left corner of the second ax for recording purposes. My custom plotting function includes:

def plot_delta_z_hist(values, datasetname, summary, ax = None):
    ...
    ...
    ...
    at = AnchoredText(
        "{0}".format(summary), prop=dict(size=10), frameon=True, loc='upper left')
        at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
        ax.add_artist(at)

and I call it like

qf.plot_delta_z_hist(valid_dataset['Delta z'], datasetname, model.summary(), ax[1])

but as you can see, it just displays None where the summary should be. How can I pass the model.summary() into the plotting function so that it displays there?

Jim421616
  • 1,434
  • 3
  • 22
  • 47
  • This question needs a [SSCCE](http://sscce.org/). Please see [How to ask a good question](https://stackoverflow.com/help/how-to-ask). Always provide a complete [mre] with **code, data, errors, current output, and expected output**, as **[formatted text](https://stackoverflow.com/help/formatting)**. If relevant, only plot images are okay. If you don't include an mre, it is likely the question will be downvoted, closed, and deleted. – Trenton McKinney Dec 08 '21 at 22:37
  • `model.summary()` returns a `NoneType` – Trenton McKinney Dec 08 '21 at 22:44
  • Does this answer your question? [Keras model.summary() object to string](https://stackoverflow.com/q/41665799/7758804) – Trenton McKinney Dec 08 '21 at 22:46
  • 1
    @TrentonMcKinney it certainly put me on the right track, thank you. – Jim421616 Dec 09 '21 at 00:54

0 Answers0