facebookresearch / torchbeast

A PyTorch Platform for Distributed RL
Apache License 2.0
734 stars 113 forks source link

can't transfer the info dictionary {} generated by env.step() to inference queue #17

Closed mschen97 closed 3 years ago

mschen97 commented 3 years ago

Thanks for your pytorch implementation, but I got a issue need some help. In my experiment with gym wrapped Starcraft2 Env, my env.step() returns five object: obs(type:np.array,size:mn)),reward(type:int),done(type:int), 0 (type:int), info(type:dict,len:2) but I can only get the first four object successfully in inference thread through inference_queue, with the fifth one turned out to be a tensor(size:11). Is it true that this inference_queue can only transfer "int" object in it's second to fifth object?

heiner commented 3 years ago

Hey mschen97,

Thanks for your interest in TorchBeast, as well as for your interest in SC2 with which I also have some history.

Our queues can only handle tensor data. That means the arguments are either tensors, or lists or dicts with string keys. If they are lists or dicts, the contents (values) need adhere to the same constraint. Nested lists/dicts are possible, but in the end all the "leaf" entries need to be tensors/np.arrays. The number of objects doesn't matter though. However, care needs to be taken that each environment step returns the same number of tensors and that these tensors are compatible (batchable).

There's no tensor type restriction as far as I remember.

Perhaps if you could share some short example code I could help you further?

mschen97 commented 3 years ago

Thanks for your replay, I have solved this problem by changing my fifth output to tensor and then form a tuple with the first output to output at the first position.Thanks!