'I get this error (ValueError: The parameter loc has invalid values) that aborts training of my agent. The environment is openai's pendulum
The environment is Pendulum from OpenAI Gym. Pytorch 1.9.1+cu102 is the package used for training the model.
This error occurs around the code :
out = Lorian(torch.tensor(observation))
distro = torch.distributions.Normal(out[0],torch.absolute(out[1]))
Error :
Traceback (most recent call last):
File "D:\pythons\pendulum\Main1.py", line 90, in <module>
distro = torch.distributions.Normal(out[0],torch.absolute(out[1]))
File "C:\Users\Mukundan1\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\distributions\normal.py", line 50, in __init__
super(Normal, self).__init__(batch_shape, validate_args=validate_args)
File "C:\Users\Mukundan1\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\distributions\distribution.py", line 53, in __init__
raise ValueError("The parameter {} has invalid values".format(param))
ValueError: The parameter loc has invalid values
the object 'distro' is sampled to get the agent's decision given the current observation. Lorian is the name of this model/neural network.
The output of the neural network can be either positive and negative but the standard deviation from mean can only be a positive since torch.absolute(out[1]) is used.
Before I started using the absolute value of out[1] the error was mostly the same except instead of 'loc' it said 'scale'.
Where is the mistake in my input of torch.distributions.Normal()?
Solution 1:[1]
you can "print" the output of the neural network.May be your output is 'nan' that case the error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | XiaoYao |
