Skip to content

Rigid assumption about Observations in acme.agents.tf.mcts #341

Open
@MJHamar

Description

@MJHamar

In acme.agents.tf.mcts.types, Observation is hinted to be a numpy ndarray

# Assumption: observations are array-like.
Observation = np.ndarray

based on this, in acme.agents.tf.mcts.acting, the MCTSActor._forward() method hard-codes a tf.expand_dims call on the observation. This makes it impossible to pass nested structures as observations to MCTS.

To fix it, we can re-define this _forward method as:

import tree
(...)
def _forward(self, observation):
        # this is all they should have done in the first place
        logits, value = self._network(tree.map_structure(lambda o: tf.expand_dims(o,axis=0), observation))
       (...)

and solve the problem.

Is there anything I am missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions