File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,9 @@ def select_action(self, state):
8282 a_mean = agent .actor .predict (state )[0 ] # extract from batch predict
8383 action = a_mean + np .random .normal (
8484 loc = 0.0 , scale = self .variance , size = a_mean .shape )
85+ action = np .clip (action ,
86+ self .env_spec ['action_bound_low' ],
87+ self .env_spec ['action_bound_high' ])
8588 return action
8689
8790 def update (self , sys_vars ):
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ def select_action(self, state):
2525 state = np .expand_dims (state , axis = 0 )
2626 if self .env_spec ['actions' ] == 'continuous' :
2727 action = agent .actor .predict (state )[0 ] + self .sample ()
28+ action = np .clip (action ,
29+ self .env_spec ['action_bound_low' ],
30+ self .env_spec ['action_bound_high' ])
2831 else :
2932 Q_state = agent .actor .predict (state )[0 ]
3033 assert Q_state .ndim == 1
You can’t perform that action at this time.
0 commit comments