# How to directly use the custom\_loss\_model metric in tensorboard

**URL:** <https://discuss.ray.io/t/how-to-directly-use-the-custom-loss-model-metric-in-tensorboard/1663>\
**Category:** RLlib\
**Created:** [April 12, 2021, 2:41am UTC](https://discuss.ray.io/t/how-to-directly-use-the-custom-loss-model-metric-in-tensorboard/1663 "2021-04-12T02:41:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shanchao\_Yang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/shanchao_yang/32/803_2.png) [@Shanchao\_Yang](https://discuss.ray.io/u/Shanchao_Yang)\
**Post date:** [April 12, 2021, 2:41am UTC](https://discuss.ray.io/t/how-to-directly-use-the-custom-loss-model-metric-in-tensorboard/1663/1 "2021-04-12T02:41:33Z")

</div>

In the [custom\_loss\_model metric.py](https://github.com/ray-project/ray/blob/master/rllib/examples/models/custom_loss_model.py#L142-L146), what is the best and direct way so that **the recorded metric can be shown in tensorboard** , without calculating the metrics again like [custom\_metrics and callbacks](https://github.com/ray-project/ray/blob/master/rllib/examples/custom_metrics_and_callbacks.py) example?  
I cannot find how to find the metrics which are already computed by the custom model.

```auto
    def metrics(self):
        return {
            "policy_loss": self.policy_loss_metric,
            "imitation_loss": self.imitation_loss_metric,
        }

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![sven1977](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sven1977/32/53_2.png) [@sven1977](https://discuss.ray.io/u/sven1977)\
**Post date:** [June 11, 2021, 10:17am UTC](https://discuss.ray.io/t/how-to-directly-use-the-custom-loss-model-metric-in-tensorboard/1663/2 "2021-06-11T10:17:14Z")

</div>

Hey @Shanchao_Yang , thanks for the question and sorry for the delay. Could you make sure that for future posts you add a category to it (e.g. “RLlib”)? That way, we’ll find it better and can answer more quickly. Thanks 🙂

I think this could possibly be a bug on RLlib. Model metrics should automatically show up in TB. …

---

<div class="post-metadata">

**Author:** ![Shanchao\_Yang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/shanchao_yang/32/803_2.png) [@Shanchao\_Yang](https://discuss.ray.io/u/Shanchao_Yang)\
**Post date:** [June 11, 2021, 11:19am UTC](https://discuss.ray.io/t/how-to-directly-use-the-custom-loss-model-metric-in-tensorboard/1663/3 "2021-06-11T11:19:07Z")

</div>

Thanks. And sorry for the lack of category of Rllib. I would be more careful in future.

Back to the question, yeah, I indeed remember that the imitation loss metric (Pytorch version) is not automatically included in TB…
