rl
rl copied to clipboard
TorchRL tutorial bug
It looks like the torchRL tutorial here throws an error.
File "~/torchrl/tut1/1.py", line 169, in <module>
advantage_module(tensordict_data)
File "~/env/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "~/env/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "~/env/lib/python3.9/site-packages/torchrl/objectives/value/advantages.py", line 80, in new_func
return fun(self, *args, **kwargs)
File "~/env/lib/python3.9/site-packages/torchrl/objectives/value/advantages.py", line 69, in new_fun
return fun(self, *args, **kwargs)
File "~/env/lib/python3.9/site-packages/tensordict/nn/common.py", line 327, in wrapper
return func(_self, tensordict, *args, **kwargs)
File "~/env/lib/python3.9/site-packages/torchrl/objectives/value/advantages.py", line 1414, in forward
with hold_out_net(self.value_network) if (
File "~/env/lib/python3.9/site-packages/torchrl/objectives/utils.py", line 415, in __enter__
self.network.requires_grad_(False)
File "~/env/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2927, in requires_grad_
p.requires_grad_(requires_grad)
File "~/env/lib/python3.9/site-packages/torch/nn/parameter.py", line 168, in __torch_function__
raise ValueError(
ValueError: Attempted to use an uninitialized parameter in <method 'requires_grad_' of 'torch._C.TensorBase' objects>. This error happens when you are using a `LazyModule` or explicitly manipu lating `torch.nn.parameter.UninitializedParameter` objects. When using LazyModules Call `forward` with a dummy batch to initialize the parameters before calling torch functions
Line 169 in my code corresponds to the advantage_module call advantage_module(tensordict_data) from the tutorial.
/assign