init_parameters function throws an error
Description
Hello. For my experiments I use nvcr.io/nvidia/pytorch:24.01-py3 docker.
I have tried to run torch_gymnasium_cartpole_dqn.py example.
But when model.init_parameters(method_name="normal_", mean=0.0, std=0.1) method executes I have got the error:
ValueError: Attempted to use an uninitialized parameter in <function normal_ at 0x74bc340b0700>. This error happens when you are using a `LazyModule` or explicitly manipulating `torch.nn.parameter.UninitializedParameter` objects. When using LazyModules Call `forward` with a dummy batch to initialize the parameters before calling torch functions
What skrl version are you using?
1.3.0
What ML framework/library version are you using?
PyTorch 2.2.0a0+81ea7a4
Additional system information
Python 3.10.12
Hi @Ojigrande
Thanks for reporting it, I see the issues... In the toni/space_tensor_conversion branch, I am working on generic spaces utils that will allow to initialize lazy torch models in Runner instances.
The solution will be to call the instantiated models https://github.com/Toni-SM/skrl/blob/2bd3b7a25ba7f4813b0154909cc3e7965f4f0a57/skrl/utils/runner/torch/runner.py#L255 with a space sample https://github.com/Toni-SM/skrl/blob/17c6f11a39295d59e99ce4eb6e694ff75bc93d3d/skrl/utils/spaces/torch/spaces.py#L240 before returning them.
Fixed in version 1.4.0: https://github.com/Toni-SM/skrl/blob/d57c8ea138e3356396a8da368f37430f75fb524a/CHANGELOG.md?plain=1#L11