# MetricsLogger error for DreamerV3

**URL:** <https://discuss.ray.io/t/metricslogger-error-for-dreamerv3/22136>\
**Category:** Configure Algorithm, Training, Evaluation, Scaling\
**Created:** [March 25, 2025, 7:39pm UTC](https://discuss.ray.io/t/metricslogger-error-for-dreamerv3/22136 "2025-03-25T19:39:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonardo\_Lamanna](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/leonardo_lamanna/32/6613_2.png) [@Leonardo\_Lamanna](https://discuss.ray.io/u/Leonardo_Lamanna)\
**Post date:** [March 25, 2025, 7:39pm UTC](https://discuss.ray.io/t/metricslogger-error-for-dreamerv3/22136/1 "2025-03-25T19:39:09Z")

</div>

I am running DreamerV3 and facing some issues apparently due to the MetricsLogger, the raised error is similar to `TypeError: Scalar tensor has no len()`, and seems to be thrown when executing the `_reduced_values()` function on a 2D EagerTensor, in particular on these 2 lines of `ray/rllib/utils/metrics/stats.py` (e.g. when `reduce_meth` is `tf.reduce_mean`):

```auto
reduce_meth = getattr(tf, "reduce_" + self._reduce_method)
reduced = reduce_meth(values)

```

The error can be reproduced through the following code (I am using Ray 2.43.0 and tensorflow 2.19.0):

```auto
# See https://discuss.ray.io/t/dreamer-v3-rllib-tensorflow-error/15127
import os
os.environ["TF_USE_LEGACY_KERAS"] = "1"

import ray
from ray.rllib.algorithms.dreamerv3.dreamerv3 import DreamerV3Config

if __name__ == " __main__":

    ray.init(local_mode=True) # debugging

    config = (
        DreamerV3Config()
        .environment(env='CartPole-v1')
        .env_runners(
            num_env_runners=0,
            num_envs_per_env_runner=1
        )
        .reporting(
            metrics_num_episodes_for_smoothing=1,
            report_images_and_videos=False,
            report_dream_data=False,
            report_individual_batch_item_stats=False,
        )
        # See Appendix A.
        .training(model_size="XS")
        .framework(
            "tf2",
            eager_tracing=False # debugging
        )
    )

    agent = config.build_algo()
    agent.train()

```

Naively replacing `reduce_meth(values)` with `reduce_meth(values[0])` seems to run but I do not think this is the ultimate solution. Is the above code the correct way to run DreamerV3?

Thank you

---

<div class="post-metadata">

**Author:** ![sashless](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sashless/32/7924_2.png) [@sashless](https://discuss.ray.io/u/sashless)\
**Post date:** [May 2, 2025, 6:03pm UTC](https://discuss.ray.io/t/metricslogger-error-for-dreamerv3/22136/2 "2025-05-02T18:03:41Z")

</div>

Facing the same error. Any recommendations apart from monkey patching ?
