# Tensorboard and Trainer pattern not working together

**URL:** <https://discuss.ai.google.dev/t/tensorboard-and-trainer-pattern-not-working-together/62486>\
**Category:** Keras\
**Tags:** tensorboard\
**Created:** [January 24, 2025, 9:59am UTC](https://discuss.ai.google.dev/t/tensorboard-and-trainer-pattern-not-working-together/62486 "2025-01-24T09:59:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geraud](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/geraud/32/9999_2.png) [@Geraud](https://discuss.ai.google.dev/u/Geraud)\
**Post date:** [January 24, 2025, 9:59am UTC](https://discuss.ai.google.dev/t/tensorboard-and-trainer-pattern-not-working-together/62486/1 "2025-01-24T09:59:20Z")

</div>

I’m using the Keras Trainer pattern as illustrated [here](https://keras.io/examples/keras_recipes/trainer_pattern/). The issue when using this pattern is that when you use Tensorboard only the top level weights are being recorded.

The reason for this is that `Tensorboard` is recording the weights for the all the layers in `self.model.layers`. But this equal to `[<Sequential name=sequential, built=True>]` and the weghts for that Sequential object is

I tried several things:

1. Passing a CallBackList to the Tensorflow Trainer when calling fit passing model\_a instead of trainer\_a, but this fails because model\_a has no optimizer
2. I tried to overwrite the `layers` method in thr Trainer object to have `recursive=True` but the weights were still not showing in TensorBoard suggesting that something else is going on

I’m open to any suggestions here. I also opened an issue on the keras repo: [Tensorboard not working with Trainer Pattern · Issue #20809 · keras-team/keras · GitHub](https://github.com/keras-team/keras/issues/20809)

---

<div class="post-metadata">

**Author:** ![jasmine\_dhantule](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/jasmine_dhantule/32/32711_2.png) [@jasmine\_dhantule](https://discuss.ai.google.dev/u/jasmine_dhantule)\
**Post date:** [June 27, 2025, 5:03am UTC](https://discuss.ai.google.dev/t/tensorboard-and-trainer-pattern-not-working-together/62486/3 "2025-06-27T05:03:02Z")

</div>

Hi @Geraud, thanks for posting this issue.

You can track updates on this issue [here](https://github.com/keras-team/keras/issues/20809)
