Model Custom Error

Hi, I try to use ComplexInputNetwork in
More examples for Building Custom Models (https://docs.ray.io/en/master/rllib-models.html)
However, I got error like this
"obs_space.original_space must be Tuple!"

I check with the type of obs_space, <class ‘gym.spaces.box.Box’>

And It seems that the initialization process don’t involve the custom environment.

Thanks.

Hi @Ethan,

Do you have a complete reproduction script?

class ComplexInputNetwork(TorchModelV2, nn.Module):

def __init__(self, obs_space, action_space, num_outputs, model_config,
             name):
    #TorchModelV2.__init__(self)
    TorchModelV2.__init__(self, obs_space, action_space, num_outputs,
                          model_config, name)
    nn.Module.__init__(self)
    super(ComplexInputNetwork, self).__init__(
        obs_space, action_space, None, model_config, name)
    # TODO: (sven) Support Dicts as well.
    #self.fc = FullyConnectedNetwork(obs_space.original_space.spaces["sensors"].spaces["position"],action_space, num_outputs, model_config, name)
    print(type(obs_space))
    self.original_space = obs_space.original_space if \
        hasattr(obs_space, "original_space") else obs_space
    assert isinstance(self.original_space, Tuple), \
        "`obs_space.original_space` must be Tuple!"
    self.num_outputs = num_outputs
    # TODO
    #in_size = self.original_space.shape[0] + action_space.n + 1
    
    for i, component in enumerate(self.original_space):
        if i == 0:
            self.pac = ModelCatalog.get_model_v2(component,
                action_space,
                num_outputs=20,
                model_config=model_config,
                framework="torch",
                name="pac_{}".format(i))
        else:
            pass
    # query + visiting + 16 neighbors
    in_size = 20 * 18
    self.layer1 = SlimFC(
        in_size=in_size, out_size=256, activation_fn="relu")
    self.layer2 = SlimFC(in_size=256, out_size=256, activation_fn="relu")
    self.out = SlimFC(
        in_size=256, out_size=self.num_outputs, activation_fn="linear")
    self.values = SlimFC(in_size=256, out_size=1, activation_fn="linear")

Here’s part of the codes. Thanks. I want to add a FCN to process the environment.