How to make observation a string in custom PyEnvironment

Viewed 30

In the tensorflow documentation for TF-Agents Environments there is an example of an environment for a simple (blackjack inspired) card game.

The __init__ looks like the following:

class CardGameEnv(py_environment.PyEnvironment):

  def __init__(self):
    self._action_spec = array_spec.BoundedArraySpec(
        shape=(), dtype=np.int32, minimum=0, maximum=1, name='action')
    self._observation_spec = array_spec.BoundedArraySpec(
        shape=(1,), dtype=np.int32, minimum=0, name='observation')
    self._state = 0
    self._episode_ended = False

But what if my observation can't be expressed as a number but needs a string? I can't simply specify dtype=str or dtype=pd.str because of the min/max attributes:

TypeError: Cannot find minimum value of <dtype: 'string'> with type <dtype: 'string'>.
  In call to configurable 'BoundedArraySpec' (<class 'tf_agents.specs.array_spec.BoundedArraySpec'>)

Anyone got any ideas?

0 Answers
Related