MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / unscale_action

Method unscale_action

roach/models/ppo_policy.py:194–206  ·  view source on GitHub ↗
(self, action: np.ndarray, eps=0.0)

Source from the content-addressed store, hash-verified

192 return action
193
194 def unscale_action(self, action: np.ndarray, eps=0.0) -> np.ndarray:
195 # input action \in [d_low, d_high]
196 # output action \in [a_low+eps, a_high-eps]
197 d_low, d_high = self.action_dist.low, self.action_dist.high # scalar
198
199 if d_low is not None and d_high is not None:
200 # batch_size = action.shape[0]
201 a_low, a_high = self.action_space.low, self.action_space.high
202 # same shape as action [batch_size, action_dim]
203 # a_high = np.tile(self.action_space.high, [batch_size, 1])
204 action = (action-d_low)/(d_high-d_low) * (a_high-a_low) + a_low
205 # action = np.clip(action, a_low+eps, a_high-eps)
206 return action
207
208 def get_init_kwargs(self) -> Dict[str, Any]:
209 init_kwargs = dict(

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected