TF-Agent: Numpy Structured Arrays with differnt dtypes in ArraySpec

160 views Asked by At

My agent needs to set an action based on a position which can be represented as a integer value (e.g. np.int32). This integer value will then be used for indexing the certain array. Furthermore, a float number will be assigned to this position. Therefore I would like to specify the action by a list of tuples where the first element for each tuple has an integer dtype and the second element a float dtype. I tried to use a numpy structured array:

self._action_spec = array_spec.ArraySpec(
        shape=(highestCoinIndex,2), dtype=[('id', np.int32), ('value', np.float64)], name='action')

This seems not to work because I get the following error:

TypeError: Cannot convert the argument `type_value`: dtype([('id', '<i4'), ('value', '<f8')]) to a TensorFlow DType. 
In call to configurable 'BoundedArraySpec' (<class 'tf_agents.specs.array_spec.BoundedArraySpec'>)

Is there a way how I can specify a list or tuple with different dtypes for e.g. self._action_spec?

0

There are 0 answers