未验证 提交 9e782d03 编写于 作者: L LI Yunxiang 提交者: GitHub

Update utils.py (#261)

* Update utils.py

* Update utils.py
上级 87e68119
......@@ -13,6 +13,7 @@
# limitations under the License.
import sys
import numpy as np
__all__ = [
'has_func', 'action_mapping', 'to_str', 'to_byte', 'is_PY2', 'is_PY3',
......@@ -45,9 +46,12 @@ def action_mapping(model_output_act, low_bound, high_bound):
Returns:
action: np.array, which value is in [low_bound, high_bound]
"""
assert np.all(((model_output_act<=1.0), (model_output_act>=-1.0))), \
'the action should be in range [-1.0, 1.0]'
assert high_bound > low_bound
action = low_bound + (model_output_act - (-1.0)) * (
(high_bound - low_bound) / 2.0)
action = np.clip(action, low_bound, high_bound)
return action
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册