Deep-reinforcement-learning-with-pytorch icon indicating copy to clipboard operation
Deep-reinforcement-learning-with-pytorch copied to clipboard

SAC Bugs

Open ZiyiLiubird opened this issue 4 years ago • 4 comments

In SAC.py, SAC_BipedalWalker-v2.py, the codes:

class NormalizedActions(gym.ActionWrapper):
    def _action(self, action):
        low = self.action_space.low
        high = self.action_space.high

        action = low + (action + 1.0) * 0.5 * (high - low)
        action = np.clip(action, low, high)

        return action

    def _reverse_action(self, action):
        low = self.action_space.low
        high = self.action_space.high

        action = 2 * (action - low) / (high - low) - 1
        action = np.clip(action, low, high)

        return action

now should be changed as follows:

class NormalizedActions(gym.ActionWrapper):
    def action(self, action):
        low = self.action_space.low
        high = self.action_space.high

        action = low + (action + 1.0) * 0.5 * (high - low)
        action = np.clip(action, low, high)

        return action

    def reverse_action(self, action):
        low = self.action_space.low
        high = self.action_space.high

        action = 2 * (action - low) / (high - low) - 1
        action = np.clip(action, low, high)

        return action

in order to adapt to the latest OpenAI Gym core.py

ZiyiLiubird avatar Jan 24 '21 05:01 ZiyiLiubird

otherwise there will be an overloaded error that " Traceback (most recent call last): File "SAC.py", line 308, in main() File "SAC.py", line 288, in main next_state, reward, done, info = env.step(np.float64(action)) File "/Users/Shared/anaconda3/envs/Pytorch/lib/python3.8/site-packages/gym/core.py", line 285, in step return self.env.step(self.action(action)) File "/Users/Shared/anaconda3/envs/Pytorch/lib/python3.8/site-packages/gym/core.py", line 288, in action raise NotImplementedError NotImplementedError "

ZiyiLiubird avatar Jan 24 '21 05:01 ZiyiLiubird

you are amazing,

hshhsjsj avatar Apr 11 '22 13:04 hshhsjsj

RuntimeError: Found dtype Double but expected Float 请问该如何解决呢

zhaoyanghandd avatar Jun 09 '22 13:06 zhaoyanghandd