All Projects → alirezamika → Evostra

alirezamika / Evostra

Licence: mit
A fast Evolution Strategy implementation in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Evostra

Polyaxon
Machine Learning Platform for Kubernetes (MLOps tools for experimentation and automation)
Stars: ✭ 2,966 (+1206.61%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Atari
AI research environment for the Atari 2600 games 🤖.
Stars: ✭ 174 (-23.35%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Free Ai Resources
🚀 FREE AI Resources - 🎓 Courses, 👷 Jobs, 📝 Blogs, 🔬 AI Research, and many more - for everyone!
Stars: ✭ 192 (-15.42%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Text summurization abstractive methods
Multiple implementations for abstractive text summurization , using google colab
Stars: ✭ 359 (+58.15%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Awesome Artificial Intelligence
A curated list of Artificial Intelligence (AI) courses, books, video lectures and papers.
Stars: ✭ 6,516 (+2770.48%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Pygame Learning Environment
PyGame Learning Environment (PLE) -- Reinforcement Learning Environment in Python.
Stars: ✭ 828 (+264.76%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Basic reinforcement learning
An introductory series to Reinforcement Learning (RL) with comprehensive step-by-step tutorials.
Stars: ✭ 826 (+263.88%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Awesome Ai Books
Some awesome AI related books and pdfs for learning and downloading, also apply some playground models for learning
Stars: ✭ 855 (+276.65%)
Mutual labels:  artificial-intelligence, ai, reinforcement-learning
Adeptrl
Reinforcement learning framework to accelerate research
Stars: ✭ 173 (-23.79%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Awesome Game Ai
Awesome Game AI materials of Multi-Agent Reinforcement Learning
Stars: ✭ 185 (-18.5%)
Mutual labels:  ai, reinforcement-learning
Go Matrix
First version of go-MATRIX, especially for TPS optimization and AI
Stars: ✭ 187 (-17.62%)
Mutual labels:  artificial-intelligence, ai
Yolov3 Object Detection With Opencv
This project implements a real-time image and video object detection classifier using pretrained yolov3 models.
Stars: ✭ 191 (-15.86%)
Mutual labels:  artificial-intelligence, ai
Elf
An End-To-End, Lightweight and Flexible Platform for Game Research
Stars: ✭ 2,057 (+806.17%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Pytorch Lightning
The lightweight PyTorch wrapper for high-performance AI research. Scale your models, not the boilerplate.
Stars: ✭ 16,641 (+7230.84%)
Mutual labels:  artificial-intelligence, ai
Pai
Resource scheduling and cluster management for AI
Stars: ✭ 2,223 (+879.3%)
Mutual labels:  artificial-intelligence, ai
Awesome Ml Courses
Awesome free machine learning and AI courses with video lectures.
Stars: ✭ 2,145 (+844.93%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Classifai
Enhance your WordPress content with Artificial Intelligence and Machine Learning services.
Stars: ✭ 188 (-17.18%)
Mutual labels:  artificial-intelligence, ai
Catalyst
🚀 Catalyst is a C# Natural Language Processing library built for speed. Inspired by spaCy's design, it brings pre-trained models, out-of-the box support for training word and document embeddings, and flexible entity recognition models.
Stars: ✭ 224 (-1.32%)
Mutual labels:  artificial-intelligence, ai
Thinc
🔮 A refreshing functional take on deep learning, compatible with your favorite libraries
Stars: ✭ 2,422 (+966.96%)
Mutual labels:  artificial-intelligence, ai
Dm control
DeepMind's software stack for physics-based simulation and Reinforcement Learning environments, using MuJoCo.
Stars: ✭ 2,592 (+1041.85%)
Mutual labels:  artificial-intelligence, reinforcement-learning

Evostra: Evolution Strategy for Python

Evolution Strategy (ES) is an optimization technique based on ideas of adaptation and evolution. You can learn more about it at https://blog.openai.com/evolution-strategies/

Installation

It's compatible with both python2 and python3.

Install from source:

.. code-block:: bash

$ python setup.py install

Install latest version from git repository using pip:

.. code-block:: bash

$ pip install git+https://github.com/alirezamika/evostra.git

Install from PyPI:

.. code-block:: bash

$ pip install evostra

(You may need to use python3 or pip3 for python3)

Sample Usages

An AI agent learning to play flappy bird using evostra <https://github.com/alirezamika/flappybird-es>_

An AI agent learning to walk using evostra <https://github.com/alirezamika/bipedal-es>_

How to use

The input weights of the EvolutionStrategy module is a list of arrays (one array with any shape for each layer of the neural network), so we can use any framework to build the model and just pass the weights to ES.

For example we can use Keras to build the model and pass its weights to ES, but here we use Evostra's built-in model FeedForwardNetwork which is much faster for our use case:

.. code:: python

import numpy as np
from evostra import EvolutionStrategy
from evostra.models import FeedForwardNetwork

# A feed forward neural network with input size of 5, two hidden layers of size 4 and output of size 3
model = FeedForwardNetwork(layer_sizes=[5, 4, 4, 3])

Now we define our get_reward function:

.. code:: python

solution = np.array([0.1, -0.4, 0.5])
inp = np.asarray([1, 2, 3, 4, 5])

def get_reward(weights):
    global solution, model, inp
    model.set_weights(weights)
    prediction = model.predict(inp)
    # here our best reward is zero
    reward = -np.sum(np.square(solution - prediction))
    return reward

Now we can build the EvolutionStrategy object and run it for some iterations:

.. code:: python

# if your task is computationally expensive, you can use num_threads > 1 to use multiple processes;
# if you set num_threads=-1, it will use number of cores available on the machine; Here we use 1 process as the
#  task is not computationally expensive and using more processes would decrease the performance due to the IPC overhead.
es = EvolutionStrategy(model.get_weights(), get_reward, population_size=20, sigma=0.1, learning_rate=0.03, decay=0.995, num_threads=1)
es.run(1000, print_step=100)

Here's the output:

.. code::

iter 100. reward: -68.819312
iter 200. reward: -0.218466
iter 300. reward: -0.110204
iter 400. reward: -0.001901
iter 500. reward: -0.000459
iter 600. reward: -0.000287
iter 700. reward: -0.000939
iter 800. reward: -0.000504
iter 900. reward: -0.000522
iter 1000. reward: -0.000178

Now we have the optimized weights and we can update our model:

.. code:: python

optimized_weights = es.get_weights()
model.set_weights(optimized_weights)

Todo

  • Add distribution support over network
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].