🧐 About
A simple and modular reinforcement learning library based on PyTorch.
🏁 Getting Started
pip install pyforce-rl
🎈 Usage
from pyforce.env import wrap_openai_gym
from pyforce.nn import default_network_components
from pyforce.agents import PPOAgent
import gym
import torch
device="cuda:0" if torch.cuda.is_available() else "cpu"
env=wrap_openai_gym(gym.make("LunarLanderContinuous-v2"))
observation_processor,hidden_layers,action_mapper=default_network_components(env)
agent=PPOAgent(
observation_processor,
hidden_layers,
action_mapper,
save_path="./evals/ppo_example",
value_lr=5e-4,
policy_lr=5e-4
).to(device)
agent.train(env,episodes=1000,train_freq=2048,eval_freq=50,render=True, batch_size=128,gamma=.99,tau=.95,clip=.2,n_steps=32,entropy_coef=.01)
🚀 Implement custom RL Agents
from pyforce.agents.base import BaseAgent
from torch import nn
class MyAgent(BaseAgent):
def __init__(self,observationprocessor,hiddenlayers,actionmapper,save_path=None):
super().__init__(save_path)
self.policy_net = nn.Sequential(observationprocessor, hiddenlayers, actionmapper)
self.value_net = ...
def forward(self, state):
return self.policy_net(state)
def get_action(self, state, eval, args):
#return action + possible additional information to be stored in the memory
return self(state).sample(), {}
def after_step(self, done, eval, args):
if not eval:
if self.env_steps % args["train_freq"] == 0 and len(self.memory) > 0:
#do training
if done and eval:
#do evaluation
⛏️ Built Using
-
PyTorch - ML Framework
-
OpenAI Gym - Environment API
-
NumPy - Numerical calculations outside PyTorch
Metadata
Release files for pyforce-rl 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyforce_rl-0.0.11-py3-none-any.whl | Python 3 | none | any | Details for pyforce_rl-0.0.11-py3-none-any.whl |
Release files / pyforce_rl-0.0.11-py3-none-any.whl
| Download URL | pyforce_rl-0.0.11-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09a8d494c44acf97bbf46ba62f7aef15ba49a5d795189d9926cbcb0a0c21f7aa
|
|
BLAKE2b-256 checksum How to use checksums |
7418bc78d8f215cff516acf64b0376420e03cdb4666ab287170a5cd70d534cf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4
|
Security for pyforce-rl 0.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.