{ "info": { "author": "Richard Herbert", "author_email": "richard.alan.herbert@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP" ], "description": "# Evolutionary Strategies in PyTorch\n\n![](https://media.giphy.com/media/30pEMgYfiPliU87swt/giphy.gif)\n\nA set of tools based on [evostra](https://github.com/alirezamika/evostra) for using [OpenAI's evolutionary strategies](https://blog.openai.com/evolution-strategies/) in PyTorch. Keras implementations using evostra will be provided with some examples.\n\nTABLE OF CONTENTS\n=================\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Run](#run)\n\n## Installation\n\nYour system needs all the prerequisites for the minimal installation of OpenAI gym. These will differ by operating system, so please refer to the [gym repository](https://github.com/openai/gym) for detailed instructions for your build. You also need to install the PyTorch distribution of your [choice](http://pytorch.org/). You can trigger CUDA ops by passing in ```-c``` or ```--cuda``` to the training examples.\n\nFollowing that, create a conda or virtualenv enviroment and run:\n\n```shell\npip install -r requirements.txt\n```\n\n## Usage\n\nYou will find the strategy classes (one as of now) within ```evolutionary_strategies/strategies```. These classes are designed to be used with PyTorch models and take two parameters: a function to get a reward and a list of PyTorch Variables that correspond to parameter layers. This can be achieved in the following manner:\n\n```python\nimport copy\nfrom functools import partial\n\nfrom evolution.strategies import EvolutionModule\n\n\ndef get_reward(model, weights):\n \"\"\"\n This function runs your model and generates a reward\n \"\"\"\n cloned_model = copy.deepcopy(model)\n for i, param in enumerate(cloned_model.parameters()):\n try:\n param.data = weights[i]\n except:\n param.data = weights[i].data\n\n # run environment and return reward as an integer or float\n return 100\n\n\nmodel = generate_pytorch_model()\n# EvolutionModule runs the population in a ThreadPool, so\n# if you need to inject other arguments, you can do that\n# using the partial tool\npartial_func = partial(get_reward, model=model)\nmother_parameters = list(model.parameters())\n\nes = EvolutionModule(\n mother_parameters, partial_func, population_size=100,\n sigma=0.1, learning_rate=0.001,\n reward_goal=200, consecutive_goal_stopping=20,\n threadcount=10, cuda=cuda, render_test=True\n)\n```\n\n* EvolutionModule\n - init\n - parameters (list of PyTorch Variables)\n - reward_function => float (runs episode and returns a reward)\n - population_size=50\n - sigma=0.1\n - learning_rate=0.001\n - decay=1.0\n - sigma_decay=1.0\n - threadcount=4\n - render_test=False\n - cuda=False\n - reward_goal=None\n - consecutive_goal_stopping=None (stops after n tests consecutively return rewards equal-to or greater-than goal)\n - save_path=None (path to save weights at test times)\n - run\n - iterations\n - print_step=10 (frequency with which to run test and save weights)\n\n## Run\n\nYou can run the examples in the following manner:\n\n```shell\nPYTHONPATH=. python evolutionary_strategies/examples/cartpole/train_pytorch.py --weights_path cartpole_weights.p\n```\n\n## Examples\n\n### Lunar Lander\n\nSolved in 1200~ iterations: population=100, sigma=0.01, learning_rate=0.001.\n\n![](https://media.giphy.com/media/30pEMgYfiPliU87swt/giphy.gif)\n\n### Cartpole\n\nSolved in 200 iterations: population=10, sigma=0.1, learning_rate=0.001.\n\n![](https://media.giphy.com/media/5h9xfw3BXvztG4HVBi/giphy.gif)\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/staturecrane/PyTorch-ES", "keywords": "machine learning,ai,evolutionary strategies,reinforcement learning,pytorch", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pytorch-es", "package_url": "https://pypi.org/project/pytorch-es/", "platform": "", "project_url": "https://pypi.org/project/pytorch-es/", "project_urls": { "Homepage": "https://github.com/staturecrane/PyTorch-ES" }, "release_url": "https://pypi.org/project/pytorch-es/0.1.1/", "requires_dist": [ "evostra (==1.0.1)", "gym (==0.10.4)", "gym[box2d] (==0.10.4)", "gym[atari] (==0.10.4)", "keras (==2.1.5)", "numpy (==1.14.2)", "Pillow (==5.0.0)", "scikit-image (==0.13.1)", "tensorflow (==1.6.0)" ], "requires_python": "", "summary": "Evolutionary Strategies using PyTorch", "version": "0.1.1" }, "last_serial": 3722715, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "685b60bcc6b08da8e6cde4860cc5b1c5", "sha256": "fca8a2bef12296f43d018d159df57ad906a7bf1600220ca93ca321f3ab2b3e01" }, "downloads": -1, "filename": "pytorch_es-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "685b60bcc6b08da8e6cde4860cc5b1c5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5631, "upload_time": "2018-03-31T20:25:31", "url": "https://files.pythonhosted.org/packages/96/66/915fac37d39246bc685cfacc07aecb8f581b214ae4f865c0270770e475cf/pytorch_es-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "756d3b619a453fe62f9f322dbb090228", "sha256": "7a1f550b0e883d3245ef9166be1307ef1d434d3544d0af439aba0a6334854455" }, "downloads": -1, "filename": "pytorch-es-0.1.0.tar.gz", "has_sig": false, "md5_digest": "756d3b619a453fe62f9f322dbb090228", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3385, "upload_time": "2018-03-31T20:25:32", "url": "https://files.pythonhosted.org/packages/32/15/3837099ef3acfc5d51e676d0ba69cbf46435ec5dc08af4eefa3e79484525/pytorch-es-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "66f916843dce316cacee139795b537a7", "sha256": "37919fa08d4ee7fd715a21aeab65d1df9f72356c81fa2063dda539b6ade0b0a8" }, "downloads": -1, "filename": "pytorch_es-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "66f916843dce316cacee139795b537a7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7524, "upload_time": "2018-03-31T20:42:18", "url": "https://files.pythonhosted.org/packages/d7/fb/a2b86d4636bdc57786bef54b88e4b33f2d664640c877721949ab2d1b7f53/pytorch_es-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d745caea63d0ca4df6efe0658704a38f", "sha256": "3a4929f814853211777ea6353ad6f76fc1de9b8f598a5aaef72edd15ec58d415" }, "downloads": -1, "filename": "pytorch_es-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d745caea63d0ca4df6efe0658704a38f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4547, "upload_time": "2018-03-31T20:42:19", "url": "https://files.pythonhosted.org/packages/85/a0/7f14c0fe31657cc83fb9b37acda72296c0d4bac750250d2ce11c303f12a4/pytorch_es-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "66f916843dce316cacee139795b537a7", "sha256": "37919fa08d4ee7fd715a21aeab65d1df9f72356c81fa2063dda539b6ade0b0a8" }, "downloads": -1, "filename": "pytorch_es-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "66f916843dce316cacee139795b537a7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7524, "upload_time": "2018-03-31T20:42:18", "url": "https://files.pythonhosted.org/packages/d7/fb/a2b86d4636bdc57786bef54b88e4b33f2d664640c877721949ab2d1b7f53/pytorch_es-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d745caea63d0ca4df6efe0658704a38f", "sha256": "3a4929f814853211777ea6353ad6f76fc1de9b8f598a5aaef72edd15ec58d415" }, "downloads": -1, "filename": "pytorch_es-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d745caea63d0ca4df6efe0658704a38f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4547, "upload_time": "2018-03-31T20:42:19", "url": "https://files.pythonhosted.org/packages/85/a0/7f14c0fe31657cc83fb9b37acda72296c0d4bac750250d2ce11c303f12a4/pytorch_es-0.1.1.tar.gz" } ] }