I was able to solve this issue by casting the custom metric into its appropriate type. So e.g.
some_value = 10
some_string = 'abc'
some_list = [0, 0.5, 0.99]
self.stats = {
"some_value ": some_value,
"some_list ": some_list,
"some_string ": some_string,
}
I first tried using this method as the error mentioned it must be a string or Tensor.
"some_value ": tf.strings.as_string(some_value)
which at least solved the issue but the resulting stats were byte encoded strings e.g. b'some_value'
'[b''0.000000'' b''0.500000'' b''0.99'']'
Eventually, I saw in another rllib policy that values are being casted, so I did as below
some_value = 10
some_string = 'abc'
some_list = [0, 0.5, 0.99]
self.stats = {
"some_value ": tf.cast(some_value, tf.int64),
"some_list ": tf.cast(some_list, tf.float64),,
"some_string ": tf.cast(some_string, tf.string),,
}
which gave me the stats I was looking for.