reinforced-lib


Namereinforced-lib JSON
Version 1.2.3 PyPI version JSON
download
home_pageNone
SummaryReinforcement learning library
upload_time2025-07-30 10:45:52
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.12
licenseAttribution 4.0 International ======================================================================= Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. Using Creative Commons Public Licenses Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC- licensed material, or material used under an exception or limitation to copyright. More considerations for licensors: wiki.creativecommons.org/Considerations_for_licensors Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason--for example, because of any applicable exception or limitation to copyright--then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More_considerations for the public: wiki.creativecommons.org/Considerations_for_licensees ======================================================================= Creative Commons Attribution 4.0 International Public License By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. Section 1 -- Definitions. a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. Section 2 -- Scope. a. License grant. 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: a. reproduce and Share the Licensed Material, in whole or in part; and b. produce, reproduce, and Share Adapted Material. 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 3. Term. The term of this Public License is specified in Section 6(a). 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a) (4) never produces Adapted Material. 5. Downstream recipients. a. Offer from the Licensor -- Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. b. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). b. Other rights. 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 2. Patent and trademark rights are not licensed under this Public License. 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. Section 3 -- License Conditions. Your exercise of the Licensed Rights is expressly made subject to the following conditions. a. Attribution. 1. If You Share the Licensed Material (including in modified form), You must: a. retain the following if it is supplied by the Licensor with the Licensed Material: i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); ii. a copyright notice; iii. a notice that refers to this Public License; iv. a notice that refers to the disclaimer of warranties; v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. Section 4 -- Sui Generis Database Rights. Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. Section 5 -- Disclaimer of Warranties and Limitation of Liability. a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. Section 6 -- Term and Termination. a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 2. upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. Section 7 -- Other Terms and Conditions. a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. Section 8 -- Interpretation. a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. ======================================================================= Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. Creative Commons may be contacted at creativecommons.org.
keywords deep-reinforcement-learning jax library machine-learning reinforcement-learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Reinforced-lib: Reinforcement learning library

[![PyPI version][pypi-badge]][pypi]
[![License: CC-BY 4.0][license-badge]][license]
[![build and test][tests-badge]][github-actions]
[![Documentation Status][rtd-badge]][documentation]
[![DOI](https://img.shields.io/badge/DOI-10.1016/j.softx.2024.101706-blue.svg)](https://doi.org/10.1016/j.softx.2024.101706)

[pypi-badge]: https://img.shields.io/pypi/v/reinforced-lib
[pypi]: https://pypi.org/project/reinforced-lib/
[license-badge]: https://img.shields.io/badge/Licenses-CC_BY_4.0-brightgreen
[license]: https://github.com/m-wojnar/reinforced-lib/blob/main/LICENSE
[tests-badge]: https://github.com/m-wojnar/reinforced-lib/actions/workflows/python-package.yml/badge.svg
[github-actions]: https://github.com/m-wojnar/reinforced-lib/actions
[rtd-badge]: https://readthedocs.org/projects/reinforced-lib/badge/?version=latest
[documentation]: https://reinforced-lib.readthedocs.io/en/latest/

**Introducing Reinforced-lib:** a lightweight Python library for the rapid development of reinforcement-learning (RL) 
solutions. It is open-source, prioritizes ease of use, provides comprehensive documentation, and offers both deep 
reinforcement learning (DRL) and classic non-neural agents. Built on [JAX](https://jax.readthedocs.io/en/latest/), 
it facilitates exporting trained models to embedded devices, and makes it great for research and prototyping with RL 
algorithms. Access to JAX's just-in-time (JIT) compilation ensures high-performance results.

## Installation

You can install the latest version of Reinforced-lib from PyPI:

```bash
pip install reinforced-lib
```

To have easy access to the [example files](https://github.com/m-wojnar/reinforced-lib/tree/main/examples)
you can clone the source code from our repository, and then install it locally with pip:

```bash
git clone git@github.com:m-wojnar/reinforced-lib.git
cd reinforced-lib
pip install -e .
```

In the spirit of making Reinforced-lib a lightweight solution, we include only the necessary dependencies in the base 
requirements. To fully benefit from Reinforced-lib's conveniences, such as TF Lite export, install with the "full" suffix:

```bash
pip install ".[full]"
```

## Key components

Reinforced-lib facilitates seamless interaction between RL agents and the environment. Here are the key components 
within of the library, represented in the API as different modules.

- **RLib** - The core module which provides a simple and intuitive interface to manage agents, use extensions, 
  and configure the logging system. Even if you're not an RL expert, *RLib* makes it easy to  implement the 
  agent-environment interaction loop.

- **Agents** - Choose from a variety of RL agents available in the *Agents* module. These agents are designed to be 
  versatile and work with any environment. If needed, you can even create your own agents using our documented recipes.

- **Extensions** - Enhance agent observations with domain-specific knowledge by adding a suitable extension from the 
  *Extensions* module. This module enables seamless agent switching and parameter tuning without extensive reconfiguration.

- **Loggers** - This module allows you to monitor agent-environment interactions. Customize and adapt logging to your 
  specific needs, capturing training metrics, internal agent state, or environment observations. The library includes 
  various loggers for creating plots and output files, simplifying visualization and data processing.

The figure below provides a visual representation of Reinforced-lib and the data-flow between its modules.

<img src="docs/resources/data-flow.png" width="600">

## JAX Backend

Our library is built on top of JAX, a high-performance numerical computing library. JAX makes it easy to implement 
RL algorithms efficiently. It provides powerful transformations, including JIT compilation, automatic differentiation, 
vectorization, and parallelization. Our library is fully compatible with DeepMind's JAX ecosystem, granting access to 
state-of-the-art RL models and helper libraries. JIT compilation significantly accelerates execution and ensures 
portability across different architectures (CPUs, GPUs, TPUs) without requiring code modifications. 
JAX offers another benefit through its robust pseudorandom number generator system, employed in our library to 
guarantee result reproducibility. This critical aspect of scientific research is frequently underestimated but 
remains highly significant.

## Edge Device Export

Reinforced-lib is designed to work seamlessly on wireless, low-powered devices, where resources are limited. It's the 
perfect solution for energy-constrained environments that may struggle with other ML frameworks. You can export your 
trained models to [TensorFlow Lite](https://www.tensorflow.org/lite) with ease, reducing runtime overhead and 
optimizing performance. This means you can deploy RL agents on resource-limited devices efficiently.

## Example code

Experience the simplicity of our library and witness the fundamental agent-environment interaction loop with our 
straightforward example. This code can by used to train a deep Q-learning agent on the `CartPole-v1` environment 
effortlessly using Reinforced-lib.

```python
import gymnasium as gym
import optax
from chex import Array
from flax import linen as nn

from reinforced_lib import RLib
from reinforced_lib.agents.deep import DQN
from reinforced_lib.exts import Gymnasium


class QNetwork(nn.Module):
    @nn.compact
    def __call__(self, x: Array) -> Array:
        x = nn.Dense(256)(x)
        x = nn.relu(x)
        return nn.Dense(2)(x)


if __name__ == '__main__':
    rl = RLib(
        agent_type=DQN,
        agent_params={
            'q_network': QNetwork(),
            'optimizer': optax.rmsprop(3e-4, decay=0.95, eps=1e-2),
        },
        ext_type=Gymnasium,
        ext_params={'env_id': 'CartPole-v1'}
    )

    for epoch in range(300):
        env = gym.make('CartPole-v1', render_mode='human')

        _, _ = env.reset()
        action = env.action_space.sample()
        terminal = False

        while not terminal:
            env_state = env.step(action.item())
            action = rl.sample(*env_state)
            terminal = env_state[2] or env_state[3]
```

## Citing Reinforced-lib

To cite this repository, please use the following BibTeX entry for the Reinforced-lib paper:

```bibtex
@article{reinforcedlib2022,
  author = {Maksymilian Wojnar and Szymon Szott and Krzysztof Rusek and Wojciech Ciezobka},
  title = {{R}einforced-lib: {R}apid prototyping of reinforcement learning solutions},
  journal = {SoftwareX},
  volume = {26},
  pages = {101706},
  year = {2024},
  issn = {2352-7110},
  doi = {https://doi.org/10.1016/j.softx.2024.101706},
  url = {https://www.sciencedirect.com/science/article/pii/S2352711024000773}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "reinforced-lib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.12",
    "maintainer_email": null,
    "keywords": "deep-reinforcement-learning, jax, library, machine-learning, reinforcement-learning",
    "author": null,
    "author_email": "Maksymilian Wojnar <mwojnar@agh.edu.pl>, Wojciech Ci\u0119\u017cobka <wciezobka@agh.edu.pl>, Krzysztof Rusek <krusek@agh.edu.pl>",
    "download_url": "https://files.pythonhosted.org/packages/ed/75/51587ff55016343b353a15d00e0d194b90dcd9bb0442f0a7dd84d1819aa3/reinforced_lib-1.2.3.tar.gz",
    "platform": null,
    "description": "# Reinforced-lib: Reinforcement learning library\n\n[![PyPI version][pypi-badge]][pypi]\n[![License: CC-BY 4.0][license-badge]][license]\n[![build and test][tests-badge]][github-actions]\n[![Documentation Status][rtd-badge]][documentation]\n[![DOI](https://img.shields.io/badge/DOI-10.1016/j.softx.2024.101706-blue.svg)](https://doi.org/10.1016/j.softx.2024.101706)\n\n[pypi-badge]: https://img.shields.io/pypi/v/reinforced-lib\n[pypi]: https://pypi.org/project/reinforced-lib/\n[license-badge]: https://img.shields.io/badge/Licenses-CC_BY_4.0-brightgreen\n[license]: https://github.com/m-wojnar/reinforced-lib/blob/main/LICENSE\n[tests-badge]: https://github.com/m-wojnar/reinforced-lib/actions/workflows/python-package.yml/badge.svg\n[github-actions]: https://github.com/m-wojnar/reinforced-lib/actions\n[rtd-badge]: https://readthedocs.org/projects/reinforced-lib/badge/?version=latest\n[documentation]: https://reinforced-lib.readthedocs.io/en/latest/\n\n**Introducing Reinforced-lib:** a lightweight Python library for the rapid development of reinforcement-learning (RL) \nsolutions. It is open-source, prioritizes ease of use, provides comprehensive documentation, and offers both deep \nreinforcement learning (DRL) and classic non-neural agents. Built on [JAX](https://jax.readthedocs.io/en/latest/), \nit facilitates exporting trained models to embedded devices, and makes it great for research and prototyping with RL \nalgorithms. Access to JAX's just-in-time (JIT) compilation ensures high-performance results.\n\n## Installation\n\nYou can install the latest version of Reinforced-lib from PyPI:\n\n```bash\npip install reinforced-lib\n```\n\nTo have easy access to the [example files](https://github.com/m-wojnar/reinforced-lib/tree/main/examples)\nyou can clone the source code from our repository, and then install it locally with pip:\n\n```bash\ngit clone git@github.com:m-wojnar/reinforced-lib.git\ncd reinforced-lib\npip install -e .\n```\n\nIn the spirit of making Reinforced-lib a lightweight solution, we include only the necessary dependencies in the base \nrequirements. To fully benefit from Reinforced-lib's conveniences, such as TF Lite export, install with the \"full\" suffix:\n\n```bash\npip install \".[full]\"\n```\n\n## Key components\n\nReinforced-lib facilitates seamless interaction between RL agents and the environment. Here are the key components \nwithin of the library, represented in the API as different modules.\n\n- **RLib** - The core module which provides a simple and intuitive interface to manage agents, use extensions, \n  and configure the logging system. Even if you're not an RL expert, *RLib* makes it easy to  implement the \n  agent-environment interaction loop.\n\n- **Agents** - Choose from a variety of RL agents available in the *Agents* module. These agents are designed to be \n  versatile and work with any environment. If needed, you can even create your own agents using our documented recipes.\n\n- **Extensions** - Enhance agent observations with domain-specific knowledge by adding a suitable extension from the \n  *Extensions* module. This module enables seamless agent switching and parameter tuning without extensive reconfiguration.\n\n- **Loggers** - This module allows you to monitor agent-environment interactions. Customize and adapt logging to your \n  specific needs, capturing training metrics, internal agent state, or environment observations. The library includes \n  various loggers for creating plots and output files, simplifying visualization and data processing.\n\nThe figure below provides a visual representation of Reinforced-lib and the data-flow between its modules.\n\n<img src=\"docs/resources/data-flow.png\" width=\"600\">\n\n## JAX Backend\n\nOur library is built on top of JAX, a high-performance numerical computing library. JAX makes it easy to implement \nRL algorithms efficiently. It provides powerful transformations, including JIT compilation, automatic differentiation, \nvectorization, and parallelization. Our library is fully compatible with DeepMind's JAX ecosystem, granting access to \nstate-of-the-art RL models and helper libraries. JIT compilation significantly accelerates execution and ensures \nportability across different architectures (CPUs, GPUs, TPUs) without requiring code modifications. \nJAX offers another benefit through its robust pseudorandom number generator system, employed in our library to \nguarantee result reproducibility. This critical aspect of scientific research is frequently underestimated but \nremains highly significant.\n\n## Edge Device Export\n\nReinforced-lib is designed to work seamlessly on wireless, low-powered devices, where resources are limited. It's the \nperfect solution for energy-constrained environments that may struggle with other ML frameworks. You can export your \ntrained models to [TensorFlow Lite](https://www.tensorflow.org/lite) with ease, reducing runtime overhead and \noptimizing performance. This means you can deploy RL agents on resource-limited devices efficiently.\n\n## Example code\n\nExperience the simplicity of our library and witness the fundamental agent-environment interaction loop with our \nstraightforward example. This code can by used to train a deep Q-learning agent on the `CartPole-v1` environment \neffortlessly using Reinforced-lib.\n\n```python\nimport gymnasium as gym\nimport optax\nfrom chex import Array\nfrom flax import linen as nn\n\nfrom reinforced_lib import RLib\nfrom reinforced_lib.agents.deep import DQN\nfrom reinforced_lib.exts import Gymnasium\n\n\nclass QNetwork(nn.Module):\n    @nn.compact\n    def __call__(self, x: Array) -> Array:\n        x = nn.Dense(256)(x)\n        x = nn.relu(x)\n        return nn.Dense(2)(x)\n\n\nif __name__ == '__main__':\n    rl = RLib(\n        agent_type=DQN,\n        agent_params={\n            'q_network': QNetwork(),\n            'optimizer': optax.rmsprop(3e-4, decay=0.95, eps=1e-2),\n        },\n        ext_type=Gymnasium,\n        ext_params={'env_id': 'CartPole-v1'}\n    )\n\n    for epoch in range(300):\n        env = gym.make('CartPole-v1', render_mode='human')\n\n        _, _ = env.reset()\n        action = env.action_space.sample()\n        terminal = False\n\n        while not terminal:\n            env_state = env.step(action.item())\n            action = rl.sample(*env_state)\n            terminal = env_state[2] or env_state[3]\n```\n\n## Citing Reinforced-lib\n\nTo cite this repository, please use the following BibTeX entry for the Reinforced-lib paper:\n\n```bibtex\n@article{reinforcedlib2022,\n  author = {Maksymilian Wojnar and Szymon Szott and Krzysztof Rusek and Wojciech Ciezobka},\n  title = {{R}einforced-lib: {R}apid prototyping of reinforcement learning solutions},\n  journal = {SoftwareX},\n  volume = {26},\n  pages = {101706},\n  year = {2024},\n  issn = {2352-7110},\n  doi = {https://doi.org/10.1016/j.softx.2024.101706},\n  url = {https://www.sciencedirect.com/science/article/pii/S2352711024000773}\n}\n```\n",
    "bugtrack_url": null,
    "license": "Attribution 4.0 International\n        \n        =======================================================================\n        \n        Creative Commons Corporation (\"Creative Commons\") is not a law firm and\n        does not provide legal services or legal advice. Distribution of\n        Creative Commons public licenses does not create a lawyer-client or\n        other relationship. Creative Commons makes its licenses and related\n        information available on an \"as-is\" basis. Creative Commons gives no\n        warranties regarding its licenses, any material licensed under their\n        terms and conditions, or any related information. Creative Commons\n        disclaims all liability for damages resulting from their use to the\n        fullest extent possible.\n        \n        Using Creative Commons Public Licenses\n        \n        Creative Commons public licenses provide a standard set of terms and\n        conditions that creators and other rights holders may use to share\n        original works of authorship and other material subject to copyright\n        and certain other rights specified in the public license below. The\n        following considerations are for informational purposes only, are not\n        exhaustive, and do not form part of our licenses.\n        \n             Considerations for licensors: Our public licenses are\n             intended for use by those authorized to give the public\n             permission to use material in ways otherwise restricted by\n             copyright and certain other rights. Our licenses are\n             irrevocable. Licensors should read and understand the terms\n             and conditions of the license they choose before applying it.\n             Licensors should also secure all rights necessary before\n             applying our licenses so that the public can reuse the\n             material as expected. Licensors should clearly mark any\n             material not subject to the license. This includes other CC-\n             licensed material, or material used under an exception or\n             limitation to copyright. More considerations for licensors:\n        \twiki.creativecommons.org/Considerations_for_licensors\n        \n             Considerations for the public: By using one of our public\n             licenses, a licensor grants the public permission to use the\n             licensed material under specified terms and conditions. If\n             the licensor's permission is not necessary for any reason--for\n             example, because of any applicable exception or limitation to\n             copyright--then that use is not regulated by the license. Our\n             licenses grant only permissions under copyright and certain\n             other rights that a licensor has authority to grant. Use of\n             the licensed material may still be restricted for other\n             reasons, including because others have copyright or other\n             rights in the material. A licensor may make special requests,\n             such as asking that all changes be marked or described.\n             Although not required by our licenses, you are encouraged to\n             respect those requests where reasonable. More_considerations\n             for the public:\n        \twiki.creativecommons.org/Considerations_for_licensees\n        \n        =======================================================================\n        \n        Creative Commons Attribution 4.0 International Public License\n        \n        By exercising the Licensed Rights (defined below), You accept and agree\n        to be bound by the terms and conditions of this Creative Commons\n        Attribution 4.0 International Public License (\"Public License\"). To the\n        extent this Public License may be interpreted as a contract, You are\n        granted the Licensed Rights in consideration of Your acceptance of\n        these terms and conditions, and the Licensor grants You such rights in\n        consideration of benefits the Licensor receives from making the\n        Licensed Material available under these terms and conditions.\n        \n        \n        Section 1 -- Definitions.\n        \n          a. Adapted Material means material subject to Copyright and Similar\n             Rights that is derived from or based upon the Licensed Material\n             and in which the Licensed Material is translated, altered,\n             arranged, transformed, or otherwise modified in a manner requiring\n             permission under the Copyright and Similar Rights held by the\n             Licensor. For purposes of this Public License, where the Licensed\n             Material is a musical work, performance, or sound recording,\n             Adapted Material is always produced where the Licensed Material is\n             synched in timed relation with a moving image.\n        \n          b. Adapter's License means the license You apply to Your Copyright\n             and Similar Rights in Your contributions to Adapted Material in\n             accordance with the terms and conditions of this Public License.\n        \n          c. Copyright and Similar Rights means copyright and/or similar rights\n             closely related to copyright including, without limitation,\n             performance, broadcast, sound recording, and Sui Generis Database\n             Rights, without regard to how the rights are labeled or\n             categorized. For purposes of this Public License, the rights\n             specified in Section 2(b)(1)-(2) are not Copyright and Similar\n             Rights.\n        \n          d. Effective Technological Measures means those measures that, in the\n             absence of proper authority, may not be circumvented under laws\n             fulfilling obligations under Article 11 of the WIPO Copyright\n             Treaty adopted on December 20, 1996, and/or similar international\n             agreements.\n        \n          e. Exceptions and Limitations means fair use, fair dealing, and/or\n             any other exception or limitation to Copyright and Similar Rights\n             that applies to Your use of the Licensed Material.\n        \n          f. Licensed Material means the artistic or literary work, database,\n             or other material to which the Licensor applied this Public\n             License.\n        \n          g. Licensed Rights means the rights granted to You subject to the\n             terms and conditions of this Public License, which are limited to\n             all Copyright and Similar Rights that apply to Your use of the\n             Licensed Material and that the Licensor has authority to license.\n        \n          h. Licensor means the individual(s) or entity(ies) granting rights\n             under this Public License.\n        \n          i. Share means to provide material to the public by any means or\n             process that requires permission under the Licensed Rights, such\n             as reproduction, public display, public performance, distribution,\n             dissemination, communication, or importation, and to make material\n             available to the public including in ways that members of the\n             public may access the material from a place and at a time\n             individually chosen by them.\n        \n          j. Sui Generis Database Rights means rights other than copyright\n             resulting from Directive 96/9/EC of the European Parliament and of\n             the Council of 11 March 1996 on the legal protection of databases,\n             as amended and/or succeeded, as well as other essentially\n             equivalent rights anywhere in the world.\n        \n          k. You means the individual or entity exercising the Licensed Rights\n             under this Public License. Your has a corresponding meaning.\n        \n        \n        Section 2 -- Scope.\n        \n          a. License grant.\n        \n               1. Subject to the terms and conditions of this Public License,\n                  the Licensor hereby grants You a worldwide, royalty-free,\n                  non-sublicensable, non-exclusive, irrevocable license to\n                  exercise the Licensed Rights in the Licensed Material to:\n        \n                    a. reproduce and Share the Licensed Material, in whole or\n                       in part; and\n        \n                    b. produce, reproduce, and Share Adapted Material.\n        \n               2. Exceptions and Limitations. For the avoidance of doubt, where\n                  Exceptions and Limitations apply to Your use, this Public\n                  License does not apply, and You do not need to comply with\n                  its terms and conditions.\n        \n               3. Term. The term of this Public License is specified in Section\n                  6(a).\n        \n               4. Media and formats; technical modifications allowed. The\n                  Licensor authorizes You to exercise the Licensed Rights in\n                  all media and formats whether now known or hereafter created,\n                  and to make technical modifications necessary to do so. The\n                  Licensor waives and/or agrees not to assert any right or\n                  authority to forbid You from making technical modifications\n                  necessary to exercise the Licensed Rights, including\n                  technical modifications necessary to circumvent Effective\n                  Technological Measures. For purposes of this Public License,\n                  simply making modifications authorized by this Section 2(a)\n                  (4) never produces Adapted Material.\n        \n               5. Downstream recipients.\n        \n                    a. Offer from the Licensor -- Licensed Material. Every\n                       recipient of the Licensed Material automatically\n                       receives an offer from the Licensor to exercise the\n                       Licensed Rights under the terms and conditions of this\n                       Public License.\n        \n                    b. No downstream restrictions. You may not offer or impose\n                       any additional or different terms or conditions on, or\n                       apply any Effective Technological Measures to, the\n                       Licensed Material if doing so restricts exercise of the\n                       Licensed Rights by any recipient of the Licensed\n                       Material.\n        \n               6. No endorsement. Nothing in this Public License constitutes or\n                  may be construed as permission to assert or imply that You\n                  are, or that Your use of the Licensed Material is, connected\n                  with, or sponsored, endorsed, or granted official status by,\n                  the Licensor or others designated to receive attribution as\n                  provided in Section 3(a)(1)(A)(i).\n        \n          b. Other rights.\n        \n               1. Moral rights, such as the right of integrity, are not\n                  licensed under this Public License, nor are publicity,\n                  privacy, and/or other similar personality rights; however, to\n                  the extent possible, the Licensor waives and/or agrees not to\n                  assert any such rights held by the Licensor to the limited\n                  extent necessary to allow You to exercise the Licensed\n                  Rights, but not otherwise.\n        \n               2. Patent and trademark rights are not licensed under this\n                  Public License.\n        \n               3. To the extent possible, the Licensor waives any right to\n                  collect royalties from You for the exercise of the Licensed\n                  Rights, whether directly or through a collecting society\n                  under any voluntary or waivable statutory or compulsory\n                  licensing scheme. In all other cases the Licensor expressly\n                  reserves any right to collect such royalties.\n        \n        \n        Section 3 -- License Conditions.\n        \n        Your exercise of the Licensed Rights is expressly made subject to the\n        following conditions.\n        \n          a. Attribution.\n        \n               1. If You Share the Licensed Material (including in modified\n                  form), You must:\n        \n                    a. retain the following if it is supplied by the Licensor\n                       with the Licensed Material:\n        \n                         i. identification of the creator(s) of the Licensed\n                            Material and any others designated to receive\n                            attribution, in any reasonable manner requested by\n                            the Licensor (including by pseudonym if\n                            designated);\n        \n                        ii. a copyright notice;\n        \n                       iii. a notice that refers to this Public License;\n        \n                        iv. a notice that refers to the disclaimer of\n                            warranties;\n        \n                         v. a URI or hyperlink to the Licensed Material to the\n                            extent reasonably practicable;\n        \n                    b. indicate if You modified the Licensed Material and\n                       retain an indication of any previous modifications; and\n        \n                    c. indicate the Licensed Material is licensed under this\n                       Public License, and include the text of, or the URI or\n                       hyperlink to, this Public License.\n        \n               2. You may satisfy the conditions in Section 3(a)(1) in any\n                  reasonable manner based on the medium, means, and context in\n                  which You Share the Licensed Material. For example, it may be\n                  reasonable to satisfy the conditions by providing a URI or\n                  hyperlink to a resource that includes the required\n                  information.\n        \n               3. If requested by the Licensor, You must remove any of the\n                  information required by Section 3(a)(1)(A) to the extent\n                  reasonably practicable.\n        \n               4. If You Share Adapted Material You produce, the Adapter's\n                  License You apply must not prevent recipients of the Adapted\n                  Material from complying with this Public License.\n        \n        \n        Section 4 -- Sui Generis Database Rights.\n        \n        Where the Licensed Rights include Sui Generis Database Rights that\n        apply to Your use of the Licensed Material:\n        \n          a. for the avoidance of doubt, Section 2(a)(1) grants You the right\n             to extract, reuse, reproduce, and Share all or a substantial\n             portion of the contents of the database;\n        \n          b. if You include all or a substantial portion of the database\n             contents in a database in which You have Sui Generis Database\n             Rights, then the database in which You have Sui Generis Database\n             Rights (but not its individual contents) is Adapted Material; and\n        \n          c. You must comply with the conditions in Section 3(a) if You Share\n             all or a substantial portion of the contents of the database.\n        \n        For the avoidance of doubt, this Section 4 supplements and does not\n        replace Your obligations under this Public License where the Licensed\n        Rights include other Copyright and Similar Rights.\n        \n        \n        Section 5 -- Disclaimer of Warranties and Limitation of Liability.\n        \n          a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\n             EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\n             AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\n             ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\n             IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\n             WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\n             PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\n             ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\n             KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\n             ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\n        \n          b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\n             TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\n             NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\n             INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\n             COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\n             USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\n             ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\n             DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\n             IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\n        \n          c. The disclaimer of warranties and limitation of liability provided\n             above shall be interpreted in a manner that, to the extent\n             possible, most closely approximates an absolute disclaimer and\n             waiver of all liability.\n        \n        \n        Section 6 -- Term and Termination.\n        \n          a. This Public License applies for the term of the Copyright and\n             Similar Rights licensed here. However, if You fail to comply with\n             this Public License, then Your rights under this Public License\n             terminate automatically.\n        \n          b. Where Your right to use the Licensed Material has terminated under\n             Section 6(a), it reinstates:\n        \n               1. automatically as of the date the violation is cured, provided\n                  it is cured within 30 days of Your discovery of the\n                  violation; or\n        \n               2. upon express reinstatement by the Licensor.\n        \n             For the avoidance of doubt, this Section 6(b) does not affect any\n             right the Licensor may have to seek remedies for Your violations\n             of this Public License.\n        \n          c. For the avoidance of doubt, the Licensor may also offer the\n             Licensed Material under separate terms or conditions or stop\n             distributing the Licensed Material at any time; however, doing so\n             will not terminate this Public License.\n        \n          d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\n             License.\n        \n        \n        Section 7 -- Other Terms and Conditions.\n        \n          a. The Licensor shall not be bound by any additional or different\n             terms or conditions communicated by You unless expressly agreed.\n        \n          b. Any arrangements, understandings, or agreements regarding the\n             Licensed Material not stated herein are separate from and\n             independent of the terms and conditions of this Public License.\n        \n        \n        Section 8 -- Interpretation.\n        \n          a. For the avoidance of doubt, this Public License does not, and\n             shall not be interpreted to, reduce, limit, restrict, or impose\n             conditions on any use of the Licensed Material that could lawfully\n             be made without permission under this Public License.\n        \n          b. To the extent possible, if any provision of this Public License is\n             deemed unenforceable, it shall be automatically reformed to the\n             minimum extent necessary to make it enforceable. If the provision\n             cannot be reformed, it shall be severed from this Public License\n             without affecting the enforceability of the remaining terms and\n             conditions.\n        \n          c. No term or condition of this Public License will be waived and no\n             failure to comply consented to unless expressly agreed to by the\n             Licensor.\n        \n          d. Nothing in this Public License constitutes or may be interpreted\n             as a limitation upon, or waiver of, any privileges and immunities\n             that apply to the Licensor or You, including from the legal\n             processes of any jurisdiction or authority.\n        \n        \n        =======================================================================\n        \n        Creative Commons is not a party to its public\n        licenses. Notwithstanding, Creative Commons may elect to apply one of\n        its public licenses to material it publishes and in those instances\n        will be considered the \u201cLicensor.\u201d The text of the Creative Commons\n        public licenses is dedicated to the public domain under the CC0 Public\n        Domain Dedication. Except for the limited purpose of indicating that\n        material is shared under a Creative Commons public license or as\n        otherwise permitted by the Creative Commons policies published at\n        creativecommons.org/policies, Creative Commons does not authorize the\n        use of the trademark \"Creative Commons\" or any other trademark or logo\n        of Creative Commons without its prior written consent including,\n        without limitation, in connection with any unauthorized modifications\n        to any of its public licenses or any other arrangements,\n        understandings, or agreements concerning use of licensed material. For\n        the avoidance of doubt, this paragraph does not form part of the\n        public licenses.\n        \n        Creative Commons may be contacted at creativecommons.org.\n        ",
    "summary": "Reinforcement learning library",
    "version": "1.2.3",
    "project_urls": null,
    "split_keywords": [
        "deep-reinforcement-learning",
        " jax",
        " library",
        " machine-learning",
        " reinforcement-learning"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6d53e2f8f0d32dfd977dcec0e5709d41e487c2d3dc0c1a8e0b4a15a18673acd9",
                "md5": "535e346068d2b0aa6f07d87c9b6c1428",
                "sha256": "fd25e5a63539de7520604822d540d41039cedf5ec4340ddf15ec6ced6fdaa223"
            },
            "downloads": -1,
            "filename": "reinforced_lib-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "535e346068d2b0aa6f07d87c9b6c1428",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.12",
            "size": 81427,
            "upload_time": "2025-07-30T10:45:50",
            "upload_time_iso_8601": "2025-07-30T10:45:50.888968Z",
            "url": "https://files.pythonhosted.org/packages/6d/53/e2f8f0d32dfd977dcec0e5709d41e487c2d3dc0c1a8e0b4a15a18673acd9/reinforced_lib-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ed7551587ff55016343b353a15d00e0d194b90dcd9bb0442f0a7dd84d1819aa3",
                "md5": "a791954f4b99e47180c1ce56fcbde3f1",
                "sha256": "a271294a988da051b1d6108c491a6bb2f4b5e2ffa3b18f2199b4449ba4cb9692"
            },
            "downloads": -1,
            "filename": "reinforced_lib-1.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "a791954f4b99e47180c1ce56fcbde3f1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.12",
            "size": 61785,
            "upload_time": "2025-07-30T10:45:52",
            "upload_time_iso_8601": "2025-07-30T10:45:52.319648Z",
            "url": "https://files.pythonhosted.org/packages/ed/75/51587ff55016343b353a15d00e0d194b90dcd9bb0442f0a7dd84d1819aa3/reinforced_lib-1.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-30 10:45:52",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "reinforced-lib"
}
        
Elapsed time: 0.98778s