facebookresearch / Pearl

A Production-ready Reinforcement Learning AI Agent Library brought by the Applied Reinforcement Learning team at Meta.
MIT License
2.69k stars 165 forks source link

Issues when trying to use torch.jit.script() #58

Closed ValerieF412 closed 9 months ago

ValerieF412 commented 9 months ago

Hi,

I was trying to save the model by script = torch.jit.script(agent.policy_learner), however I got error stating:

RuntimeError: Module 'IdentityActionRepresentationModule' has no attribute '_max_number_actions' (This attribute exists on the Python module, but we failed to convert Python type: 'numpy.int64' to a TorchScript type. Only tensors and (possibly nested) tuples of tensors, lists, or dictsare supported as inputs or outputs of traced functions, but instead got value of type int64.. Its type was inferred; try adding a type annotation for the attribute.): File "Pearl\pearl\action_representation_modules\identity_action_representation_module.py", line 31 @property def max_number_actions(self) -> int: return self._max_number_actions

Could you look into this please? Thanks!

alexnikulkov commented 9 months ago

Do you have more details about your setup? Are you doing something custom or running one of our standard training workflows? Specifically, how is IdentityActionRepresentationModule initialized? According to type hints, max_number_actions is supposed to be an int, but it looks like it's numpy.int64 instead

rodrigodesalvobraz commented 9 months ago

Closing due to lack of response, feel free to re-open if needed.