Package: rewards-experimental
rewardsCreate custom environments and train custom agents in few lines of code.Getting started with RL is quite easy now a days. The workflow stays almost same. You create your environment. This environment is either used for from Open AI'sgymor we make custom environment usingpygameandunity. After environment creation we go for making deep RL agents, by creating our model usingtensorfloworpytorchetc.So the bottleneck mostly lies in the environment creation, integrating the environment with different libraries likegymto make agents around it and finding that best reward function. It becomes very hectic to manage all these experimentation process all by yourself.Introducingrewards, a low code RL training and experimentation platform powered by rewards.ai, rewards lets us to do those in some few lines of code. Manage all your RL experimentation and integration code in just few lines of code.what other things rewards provides?Easy experimentation and integration management in just few lines of code.Integration with[rewards-platform](GitHub - rewards-ai/training-platform).If you did' check out, think it as the open source alternative of Amazon deep racer.Beginner friendly documentation focussed on learning reinforcement learning.Getting startedOh that's very easy. First install rewards:pipinstall--upgraderewardsThis should install the latest version of rewards. After this in few lines of code you can get started by ceating your first experiment.rewards currently only support it's own racing environment. Support for more environments, custom environment and gym will come in next version.First import ourworkflowmodule. The workflow module will create setup an experimentation setup for a specific RL environment. This mainly stores theconfiguration,metrics,reward functions,model weights,environment. Once everything is stored you can easily integrate experimentation tracking servicesweights and biasesorneptune.You can check out those tutorials in our documentation.Every experiment expects some sets of configuration. A typical configuration in rewards looks like this:configs=workflow.WorkFlowConfigurations(MODE="training",LAYER_CONFIG=[[5,16],[16,3]],CHECKPOINT_FOLDER_PATH=None,CHECKPOINT_MODEL_NAME="model.pth",NUM_EPISODES=1000,CAR_SPEED=20,REWARD_FUNCTION=reward_func,PYGAME_WINDOW_TYPE="display",ENVIRONMENT_WORLD=1,SCREEN_SIZE=(1000,700),EPSILON=0.99,GAMMA=0.9,LR=0.001)Current version of rewards already assumes that it is working on it's car-race environment. In coming version we will provide support for custom env integration.Here is the meaning of each of the configuration parameters:Mode:  This states in which mode our experiment will run on. There are two types:trainingandevaluation. In training, the agent can run for multiple episodes and goes for the deep learning optimization. Inevaluationmode, there is no further optimization and it runs for a single episode.LAYER_CONFIG: Current version of rewards supports a simple neural network builder. We already assume that the input and output layer will have no of neurons of 5 and 3 respectively. Rest every number of neurons and layers can be configured.CHECKPOINT_FOLDER_PATH:  Specifies where the model checkpoints will be saved. By default it is None. If changed then it will save the model on that specific path.CHECKPOINT_MODEL_NAME: The name of the model that is to be saved. By default the name is setup to be asmodel.pth.NUM_EPISODES: The number of episodes the model should be trained.CAR_SPEED: The speed of the car while traning. The range of the speed lies from 1 to 100. It is recommended to train the agent with lower speed initially and gradually increase the speed for more generalised agent.REWARD_FUNCTION: Reward function is a function that powers reinforcement learning agents learn about the environment. Better the reward function better the learning. A sample reward function should look this:defreward_func(props)->int:reward=0ifprops["isAlive"]:reward=1obs=props["obs"]ifobs[0]<obs[-1]andprops["dir"]==-1:reward+=1ifprops["rotationVel"]==7orprops["rotationVel"]==10:reward+=1elifobs[0]>obs[-1]andprops["dir"]==1:reward+=1ifprops["rotationVel"]==7orprops["rotationVel"]==10:reward+=1else:reward+=0ifprops["rotationVel"]==15:reward+=1returnrewardHerepropsrepresents properties. This includes the properties of the agent. Here is the car. The properties includeisAlive(whether the game finished or not),obs(current radar observation),dir(current car direction)rotationVel(Car's rotational velocity)PYGAME_WINDOW_TYPE: There are two types.displaytakes out the pygame window while training the agent. Where assurfacestreams the pygame window streams as image to show to somewhere else. Usecases include to integrate to other platforms or saves as video.ENVIRONMENT_WORLD: The type of the track that is to be choosen. Fortrainingthere are three options 1/2/3. For evaluation there is one option: 1.SCREEN_SIZE: The size of the pygame window screen.GAMMA: A discount factor that determines the importance of future rewards in the RL algorithm.EPSILON: A probability value used in the epsilon-greedy strategy to balance exploration and exploitation.LR: Learning rate, A hyperparameter that controls the step size in updating the weights of a neural network during training..After configuring all the configurations and writing the reward function we call therewads.workflow.RLWorkFlowmodule that will take all the configurations and start the experiments.flow=workflow.RLWorkFlow(configs)flow.run_episodes()Setting up the project locallySetting up rewards is very easy. All you have to do is to first create a virtual environment. Creating a virtual environment is very easy:[LINUX]```bash
$virtualenv.rewards
$source.rewards/bin/activate**`[WINDOWS]`**

```bash
virtualenv .rewards
.\venv\Scripts\ActivateAfter this clone the repository. To clone the repo and move inside the directory, just type the command:$gitclonehttps://github.com/rewards-ai/rewards-SDK.git
$cdrewards-SDKpipinstallpoetryAfter this install all the dependencies by:poetryinstallThat's it. After this latest version ofrewardsget's installed and you can work on the top of it.ContributingWe will be very happy to expand the rewards community as soon as possible. Right now we expect contribution in terms of adding:Tests : Provide test scripts for testing our current rewards package.Feature requests : Feel free to request more features in the issues tab.Documentation : We are a beginner first organisation. Our documentation not only focuses on how to use rewards in their RL workflow but also to learn and get started with RL at the same time. So if you are interested in contributing that, please feel free to do so.How to build the docsrewards usesdocusaurusto create the docs. Go inside thedocs/folder and build the docs by installing the dependencies and start the docs server.$npmi
$npmrunstartRoadmaprewards is under heavy developement and updates get rolled very frequently. We are currently focussed on building our sdk such that it supports our other projects that includesrewards-apiandrewards-platform. But here are the major changes and updates we are looking forward.Introducing more games / environments under rewardsIntoducing integration with other custom pygame environmentsSupport for Open AI gym environmentsMore RL algorithms (other than DQN)Better experimentation managingSupport for stable baseline