Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jax.jit しやすいシミュレータの実装方針 #17

Closed
sotetsuk opened this issue Sep 4, 2022 · 0 comments
Closed

jax.jit しやすいシミュレータの実装方針 #17

sotetsuk opened this issue Sep 4, 2022 · 0 comments

Comments

@sotetsuk
Copy link
Owner

sotetsuk commented Sep 4, 2022

  • [必須] 可変長のforループを使わない
  • [必須] listを使わない(appendなども使わない)
  • ifのネストやforをなるべくさけ、numpyの操作をなるべく使う
  • 長い関数や深いネストをさけ、10行以内くらいの小さいpure functionになるべく分割する
    • pure functionとは副作用が起こらず、引数が同じなら同じ結果が返ってくるもののこと
  • stateが一つの行列で表現できない場合は dataclass で実装する
    • dataclassの各要素はすべて np.ndarray とし、intの場合も a: np.ndarray = np.zeros(1) といった具合にする
    • observationを生成する関数も用意する
  • actionがintや一つのベクトルで表現できない場合は、 dataclass で実装する Actionは一つのintで表現できる必要がある(legal_actionsが可変長リストになってしまうため)
    • 0~N個の連続した数字に各アクションを割り当てる必要がある。
  • legal_actionsも可変長リストはダメ。
    • ダメな例: legal_actions: List[Action] みたいなのはダメ。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant