这是indexloc提供的服务,不要输入任何密码
Skip to content

Batch refactoring #87

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

Merged
merged 11 commits into from
Jun 23, 2020
Merged

Batch refactoring #87

merged 11 commits into from
Jun 23, 2020

Conversation

duburcqa
Copy link
Collaborator

@duburcqa duburcqa commented Jun 23, 2020

  • Get rid of metadata property _meta, which simplifies and clarifies the implementation
  • Enable to initialize a Batch instance using a dict instead of individual keys only, simular to Python dict itself or gym.spaces.Dict
  • Add full support of 0-dim np.array
  • Do not sort Batch keys anymore for efficiency. Add items method. Now it mimics completely the behavior of native dict
  • Rename cat in cat_ and add cat method for consistency with in-place / out-of-place torch API
  • Add stack method, which is equivalent to torch/numpy stack method (It adds an extra dimension)
  • Preserve original data type when stacking multiple Batch/dict. 0-dim np.array must be used to get a 1-dim np.array after Batch stacking.

@duburcqa
Copy link
Collaborator Author

@Trinkle23897 Ready to be merged if you are ok with the changes

@Trinkle23897 Trinkle23897 merged commit ec27075 into thu-ml:master Jun 23, 2020
BFAnas pushed a commit to BFAnas/tianshou that referenced this pull request May 5, 2024
* Enable to stack Batch instances. Add Batch cat static method. Rename cat in cat_ since inplace.

* Properly handle Batch init using np.array of dict.

* WIP

* Get rid of metadata.

* Update UT. Replace cat by cat_ everywhere.

* Do not sort Batch keys anymore for efficiency. Add items method.

* Fix cat copy issue.

* Add unit test to chack cat and stack methods.

* Remove used import.

* Fix linter issues.

* Fix unit tests.

Co-authored-by: Alexis Duburcq <alexis.duburcq@wandercraft.eu>
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

Successfully merging this pull request may close these issues.

2 participants