x-transformers-rl


Namex-transformers-rl JSON
Version 0.0.95 PyPI version JSON
download
home_pageNone
SummaryX-Transformer for RL
upload_time2025-07-26 15:13:55
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2025 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords artificial intelligence deep learning evolution reinforcement learning transformers
VCS
bugtrack_url
requirements gymnasium moviepy x-transformers-rl
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## x-transformers-rl (wip)

Implementation of a transformer for reinforcement learning using `x-transformers`

## Install

```bash
$ pip install x-transformers-rl
```

## Usage

```python
import numpy as np

class Sim:
    def reset(self, seed = None):
        return np.random.randn(5) # state

    def step(self, actions):
        return np.random.randn(5), np.random.randn(1), False # state, reward, done

sim = Sim()

# learning

from x_transformers_rl import Learner

learner = Learner(
    state_dim = 5,
    num_actions = 2,
    reward_range = (-1., 1.),
    max_timesteps = 10,
    world_model = dict(
        attn_dim_head = 16,
        heads = 4,
        depth = 1,
    )
)

learner(sim, 100)
```

## Example

### Lunar Lander

```bash
$ pip install -r requirements.txt
```

Then

```python
$ python train_lander.py
```

## Citation

```bibtex
@inproceedings{Wang2025EvolutionaryPO,
    title = {Evolutionary Policy Optimization},
    author = {Jianren Wang and Yifan Su and Abhinav Gupta and Deepak Pathak},
    year  = {2025},
    url   = {https://api.semanticscholar.org/CorpusID:277313729}
}
```

```bibtex
@article{Schulman2017ProximalPO,
    title   = {Proximal Policy Optimization Algorithms},
    author  = {John Schulman and Filip Wolski and Prafulla Dhariwal and Alec Radford and Oleg Klimov},
    journal = {ArXiv},
    year    = {2017},
    volume  = {abs/1707.06347},
    url     = {https://api.semanticscholar.org/CorpusID:28695052}
}
```

```bibtex
@article{Farebrother2024StopRT,
    title   = {Stop Regressing: Training Value Functions via Classification for Scalable Deep RL},
    author  = {Jesse Farebrother and Jordi Orbay and Quan Ho Vuong and Adrien Ali Taiga and Yevgen Chebotar and Ted Xiao and Alex Irpan and Sergey Levine and Pablo Samuel Castro and Aleksandra Faust and Aviral Kumar and Rishabh Agarwal},
    journal = {ArXiv},
    year   = {2024},
    volume = {abs/2403.03950},
    url    = {https://api.semanticscholar.org/CorpusID:268253088}
}
```

```bibtex
@article{Lee2025HypersphericalNF,
    title   = {Hyperspherical Normalization for Scalable Deep Reinforcement Learning},
    author  = {Hojoon Lee and Youngdo Lee and Takuma Seno and Donghu Kim and Peter Stone and Jaegul Choo},
    journal = {ArXiv},
    year    = {2025},
    volume  = {abs/2502.15280},
    url     = {https://api.semanticscholar.org/CorpusID:276558261}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "x-transformers-rl",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, evolution, reinforcement learning, transformers",
    "author": null,
    "author_email": "Phil Wang <lucidrains@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/73/53/4f8aaa5f2855cc52f1fb3933bcb6ce0351acf7a3f0d50301d46b6b085898/x_transformers_rl-0.0.95.tar.gz",
    "platform": null,
    "description": "## x-transformers-rl (wip)\n\nImplementation of a transformer for reinforcement learning using `x-transformers`\n\n## Install\n\n```bash\n$ pip install x-transformers-rl\n```\n\n## Usage\n\n```python\nimport numpy as np\n\nclass Sim:\n    def reset(self, seed = None):\n        return np.random.randn(5) # state\n\n    def step(self, actions):\n        return np.random.randn(5), np.random.randn(1), False # state, reward, done\n\nsim = Sim()\n\n# learning\n\nfrom x_transformers_rl import Learner\n\nlearner = Learner(\n    state_dim = 5,\n    num_actions = 2,\n    reward_range = (-1., 1.),\n    max_timesteps = 10,\n    world_model = dict(\n        attn_dim_head = 16,\n        heads = 4,\n        depth = 1,\n    )\n)\n\nlearner(sim, 100)\n```\n\n## Example\n\n### Lunar Lander\n\n```bash\n$ pip install -r requirements.txt\n```\n\nThen\n\n```python\n$ python train_lander.py\n```\n\n## Citation\n\n```bibtex\n@inproceedings{Wang2025EvolutionaryPO,\n    title = {Evolutionary Policy Optimization},\n    author = {Jianren Wang and Yifan Su and Abhinav Gupta and Deepak Pathak},\n    year  = {2025},\n    url   = {https://api.semanticscholar.org/CorpusID:277313729}\n}\n```\n\n```bibtex\n@article{Schulman2017ProximalPO,\n    title   = {Proximal Policy Optimization Algorithms},\n    author  = {John Schulman and Filip Wolski and Prafulla Dhariwal and Alec Radford and Oleg Klimov},\n    journal = {ArXiv},\n    year    = {2017},\n    volume  = {abs/1707.06347},\n    url     = {https://api.semanticscholar.org/CorpusID:28695052}\n}\n```\n\n```bibtex\n@article{Farebrother2024StopRT,\n    title   = {Stop Regressing: Training Value Functions via Classification for Scalable Deep RL},\n    author  = {Jesse Farebrother and Jordi Orbay and Quan Ho Vuong and Adrien Ali Taiga and Yevgen Chebotar and Ted Xiao and Alex Irpan and Sergey Levine and Pablo Samuel Castro and Aleksandra Faust and Aviral Kumar and Rishabh Agarwal},\n    journal = {ArXiv},\n    year   = {2024},\n    volume = {abs/2403.03950},\n    url    = {https://api.semanticscholar.org/CorpusID:268253088}\n}\n```\n\n```bibtex\n@article{Lee2025HypersphericalNF,\n    title   = {Hyperspherical Normalization for Scalable Deep Reinforcement Learning},\n    author  = {Hojoon Lee and Youngdo Lee and Takuma Seno and Donghu Kim and Peter Stone and Jaegul Choo},\n    journal = {ArXiv},\n    year    = {2025},\n    volume  = {abs/2502.15280},\n    url     = {https://api.semanticscholar.org/CorpusID:276558261}\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Phil Wang\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "X-Transformer for RL",
    "version": "0.0.95",
    "project_urls": {
        "Homepage": "https://pypi.org/project/x-transformers-rl/",
        "Repository": "https://github.com/lucidrains/x-transformers-rl"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " evolution",
        " reinforcement learning",
        " transformers"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1ba6d84908fc80baf385e25f49b55ef902e7968d3118b3554e9d6c7dc649a3a1",
                "md5": "f42669dd01625cca97ef6bfc2356f040",
                "sha256": "3df7b255ebbd3deb95d257169ef30b0b5862a54a9353f8d94beaa4889e1622d6"
            },
            "downloads": -1,
            "filename": "x_transformers_rl-0.0.95-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f42669dd01625cca97ef6bfc2356f040",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20750,
            "upload_time": "2025-07-26T15:13:54",
            "upload_time_iso_8601": "2025-07-26T15:13:54.393183Z",
            "url": "https://files.pythonhosted.org/packages/1b/a6/d84908fc80baf385e25f49b55ef902e7968d3118b3554e9d6c7dc649a3a1/x_transformers_rl-0.0.95-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "73534f8aaa5f2855cc52f1fb3933bcb6ce0351acf7a3f0d50301d46b6b085898",
                "md5": "f776da28530395a1ab6c91daaa2069a0",
                "sha256": "0343336268f19f24b2cc8484636f7a8332f4b117f1810fc325941e2b6d15a835"
            },
            "downloads": -1,
            "filename": "x_transformers_rl-0.0.95.tar.gz",
            "has_sig": false,
            "md5_digest": "f776da28530395a1ab6c91daaa2069a0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 22028,
            "upload_time": "2025-07-26T15:13:55",
            "upload_time_iso_8601": "2025-07-26T15:13:55.673939Z",
            "url": "https://files.pythonhosted.org/packages/73/53/4f8aaa5f2855cc52f1fb3933bcb6ce0351acf7a3f0d50301d46b6b085898/x_transformers_rl-0.0.95.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-26 15:13:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucidrains",
    "github_project": "x-transformers-rl",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "gymnasium",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "moviepy",
            "specs": [
                [
                    ">=",
                    "1.0.3"
                ]
            ]
        },
        {
            "name": "x-transformers-rl",
            "specs": []
        }
    ],
    "lcname": "x-transformers-rl"
}
        
Elapsed time: 1.36821s