Giter Club home page Giter Club logo

sagemaker-template's Introduction

Sagemaker Repository Template

This repository provides a template for running reinforcement learning algorithms that trains a ml-agents for a Unity environment on Amazon AWS Sagemaker service.

In addition, it offers a configurable script to generate a custom Docker container on which training algorithms will run as training jobs on AWS Sagemaker.

Get Started with Amazon Web Services (AWS)

Here we collected some link to useful resources that can help you understand AWS and how to use the services.

In addition, we provided further description of the different components in each sub-folder. Please check also them to get a complete overview.

Steps to be up and running with Sagemaker

  • Create an AWS Account and carry out the initial security measures, such as creating a non-root user and granting them proper permissions (in our case it means full access to Sagemaker, S3 and ECR services).
  • Open Sagemaker console and create a new notebook instance. During the process it might be useful to create a new role, which will be required to execute the training jobs. In addition, a S3 bucket is automatically created and associated to this notebook instance. In case of different needs, it is still possible to create another S3 bucket as container for Sagemaker input/output data, but it might require to configure the proper permissions.
    In case you already have created a repository for your project, during the creation of the notebook there is the possibility to associate it with the notebook environment. (More details are provided in the template folder description).
  • If required, build and upload the custom Docker image tailored to allow TensorFlow interact with Unity environments (check the detailed description here).
  • Exploit the template repository to implement your own training algorithm.
  • Synch your repository project with the notebook environment and execute the job launcher.
  • Once the training job is finished, you can collect the model and potential output data from S3 associated bucket.

Note: after executing the training job, if you do not require to run further job, please stop from Sagemaker console the notebook instance. This allows yoy to save computation hours (and costs) of the AWS instance.

Use trained model for inferencing on Unity

In order to use your trained model for performing inference, that means choosing which action the agent should carry out, there are two possibilities:

  • write a custom Python inferencing script, similar to the training one, that interface with Open AI Gym to send commands to the Unity environment.
  • convert your trained model into a format that can be employed by Unity ML-Agents library.

In both cases the adopted Unity environment should be build for inferencing and not for training (unmark control checkbox in the Academy object).

On Unity ML-Agents trained model format

Unity ML-Agents library adopted a particular model format: Barracuda. Therefore, in order to use your trained model it is necessary to convert it into the proper format. In the documentation of Unity ML-Agents is explained this procedure. The idea is to first convert your neural network model into either the TensorFlow checkpoint format (.pb) or in the Open Neural Network eXchange format (.onnx). Then it would be possible to use the converter script to easily obtain the proper model format.

Note: current Barracuda version shipped with Unity ML-Agents still does not support many features and the conversion of .onnx models. Therefore it is necessary to adopt Barracuda development version, which can be found here.

sagemaker-template's People

Contributors

danibix95 avatar

Watchers

 avatar  avatar

sagemaker-template's Issues

NN models for Unity ML-agents

Discuss how to deal with the problem that any trained model should be converted into Barracuda format.
In addition this open potential future works where new images are developed (scikit-learn & Pytorch), as long as the training algorithm can save their model into TensorFlow or ONNX format, which they can be converted into Barracuda one.

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.