mirror of
https://github.com/wassname/ray.git
synced 2026-09-09 11:32:43 +08:00
SAC Performance Fixes (#6295)
* SAC Performance Fixes * Small Changes * Update sac_model.py * fix normalize wrapper * Update test_eager_support.py Co-authored-by: Eric Liang <ekhliang@gmail.com>
This commit is contained in:
committed by
Eric Liang
co-authored by
Eric Liang
parent
eca4cc7c00
commit
548df014ec
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import gym
|
||||
from gym import spaces
|
||||
import numpy as np
|
||||
|
||||
|
||||
class NormalizeActionWrapper(gym.ActionWrapper):
|
||||
"""Rescale the action space of the environment."""
|
||||
|
||||
def action(self, action):
|
||||
if not isinstance(self.env.action_space, spaces.Box):
|
||||
return action
|
||||
|
||||
# rescale the action
|
||||
low, high = self.env.action_space.low, self.env.action_space.high
|
||||
scaled_action = low + (action + 1.0) * (high - low) / 2.0
|
||||
scaled_action = np.clip(scaled_action, low, high)
|
||||
|
||||
return scaled_action
|
||||
|
||||
def reverse_action(self, action):
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user