How to adapt regular gym examples to work properly with NLE?

I’m still new to the field of reinforcement learning, and trying to bridge the gap from the included random example to something a little more complex. I’m attempting to use the minimalRL examples from this repository with NLE:

They run great when run against CartPole-v1, but when I change the environment to use NLE:

env = gym.make('CartPole-v1')

to:

env = aicrowd_gym.make("NetHackChallenge-v0") 

then I get errors like the following:

Traceback (most recent call last):
  File "a2c.py", line 156, in <module>
    prob = model.pi(torch.from_numpy(s).float())
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

The specific error will be different depending on which agent I attempt to convert, but they all seem centered around this. What is different about the return value obtained from the NLE gym in the call to reset() that can’t be converted to a numpy array of floats?

1 Like

Hi @clint_herron

The NLE observations are dictionaries, so torch cannot directly consume it.

Please refer to observation encoders used in the torchbeast model. It will need a bit of work to move it to minimalRL.

2 Likes