Code Monkey home page Code Monkey logo

ai-baselines's Introduction

ai-baselines

Swift4RL is an open source organization that explores new way of working with Reinforcement Learning combining Swift for TensorFlow (S4TF), Unity ML-Agents and possibly other environments in the future. Python has been the main programming language for data scientist for so long eventhough it has some drawbacks such as being slow, concurrency (GIL), and relying on native bindings for wiring Python with C++ and CUDA for resource intensive applications. On the other hand Swift for Tensorflow provides easy way to write custom ops, debugging, aesthetics and design which allows power users like AI researches to become productive. Another advantage of Swift is that it's been built for mobile devices. Therefore it is pretty lightweight. Wouldn't it be awesome to train baseline models by taking advantage of Unity's physic engine and deploy them on the real world mobile robots.

Requirements

  • Xcode 12
  • macOS 10.15.6 and above
  • Swift 5.3
  • Unity Hub
  • protoc-4.0.0-rc-2
  • grpc_csharp_plugin

Installation

Install rake and xcodeproj as follows and then execute rake dependencies that will generate xcode project with deployment target macOS 10.15

[sudo] gem install rake
[sudo] gem install xcodeproj
rake dependencies

DS Experiments

To run with python gym environments one must have a the python packages installed. Swift must also know where python is where the dependencies are installed.

On OSX

Install python 3.8

Install python 3.8 as a system python version, not a virtual env. We could not get that to work, e.g. in a venv or anaconda env.

brew install [email protected]

Install python dependencies

We need python dependencies for only observing training in tensorboard, other than that we use Swift for Tensorflow in the project. In your newly installed python 3.8 install dependencies. The path is on my mac "/usr/local/Frameworks/Python.framework/Versions/bin/python3"

Use your path as from the example above

PATH/python3 -m pip install tensorflow tensorboard

If you have not installed pip in the python version above do it as in here. With the python path as above.

Run with environment variable

Swift makes it possible to choose which python version to use. Documentation is here, but not the easiest to get it to work. We could not get it to work with a venv or anaconda env.

You will need to change the path to the environment inside Run/main.swift to an executable environment. Docs to create an executable environment link

PYTHON_LIBRARY=PATH/python3 swift run

Then the model should run and train a PPO model on the environment. This also saves logs to tensorboard via the python api. To run the tensorboard with correct logdir run:

tensorboard --logdir=logs

ai-baselines's People

Contributors

morpheyesh avatar ozgewhocodes avatar sercankaraoglu avatar stswn avatar tomcis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ai-baselines's Issues

Implement UnityEnvironment extending Open AI Gym interface

Open AI Gym interface is well known by data scientists and it is easy to understand. And there are existing models that works with that interface.
Therefore implementing that interface and showing that models can work both with Gym and Unity would be great feature.

Build Pipeline

Create build pipeline that generates containerized unity game environments and ai-baselines.

DoD:

  • with one docker-compose up command we should be able to run both game environment and ai-baselines all together.
  • We shouldn't need Unity Hub installation to run training or inference unless we want to build new environment from scratch. That means a docker container should be able to produce executable for instance .app artifact from Unity Project path

Implement Gym interface targeting Gym Rest Api

Initially we wanted to support Unity environment as close possible to Gym interface. Test if we have solid Interface by implementing the same interface to access Open AI Gym API.

DoD:
Show that the same model can run with both environments seamlessly.

Implement generic environments

In the initial implementation there was BaseEnv and generic continous and discrete environments. As a quick fix this is now single implementation without generics fix this and start supporting both discrete and continous environments

Dockerize swift grpc protocol generation

Currently we use make.sh script to generate swift objects from protobuf which makes code generation to depend on host system.
Instead create docker image that generates swift objects from protobof definition at the given path and refactor make.sh script with docker run statement

Refine PPO Agent

Currently PPO doesn't seem like converging. Make sure PPO implementation and/or environment-agent interaction are correct

refine RpcCommunicator

Current way in Rpc communicator implementation is not good because of the fact that blocking sleep calls. This can be much better using Futures in a proper way

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.