EzPPO
A simple, unified PPO (Proximal Policy Optimization) library for PyTorch. Supports both discrete and continuous action spaces.
Features
- Unified API: Same training loop for discrete and continuous
- Observation normalization: Online running statistics
- GAE (Generalized Advantage Estimation): For stable advantage estimation
- Clipped surrogate objective: Standard PPO clipping
- Mini-batch training: With random shuffling
- Gradient clipping: Prevents exploding gradients
- Checkpoint save/load: Resume training easily
- Multi-environment support: Parallel environments built-in
- GPU support: Automatic device management
Quick Start
Discrete Actions (CartPole)
from ezppo import DiscretePPOAgent
import gymnasium as gym
agent = DiscretePPOAgent(state_dim=4, action_dim=2)
env = gym.make("CartPole-v1")
state, _ = env.reset()
action, log_prob = agent.act(state) # Stochastic action
# action = agent.act_deterministic(state) # Greedy action (for eval)
Continuous Actions (Pendulum)
from ezppo import ContinuousPPOAgent
import gymnasium as gym
agent = ContinuousPPOAgent(state_dim=3, action_dim=1)
env = gym.make("Pendulum-v1")
state, _ = env.reset()
action, log_prob, raw_action = agent.act(state)
# action = agent.act_deterministic(state)[0] # Mean action (for eval)
Installation
pip install torch gymnasium numpy
Architecture
ezppo/
├── __init__.py # Public API
├── networks.py # DiscretePPO, ContinuousPPO, BasePPO
├── normalizer.py # RunningNormalizer
└── agents.py # DiscretePPOAgent, ContinuousPPOAgent
examples/
├── discrete_cartpole.py
└── continuous_pendulum.py
Training Loop Template
trajectory = []
max_trajectory = 2048
for episode in range(num_episodes):
state, _ = env.reset()
done = False
while not done:
action, log_prob = agent.act(state)
next_state, reward, terminated, truncated, _ = env.step(action.item())
done = terminated or truncated
trajectory.append((state, action.item(), reward, log_prob.item(),
next_state, terminated))
state = next_state
if len(trajectory) >= max_trajectory:
agent.train(num_epochs=4, batch_size=64)
trajectory.clear()
API Reference
Networks
| Class | Purpose |
|---|---|
BasePPO |
Base class with configurable architecture |
DiscretePPO |
Discrete actions → logits output |
ContinuousPPO |
Continuous actions → mean + learnable log_std |
Agents
| Class | Purpose |
|---|---|
DiscretePPOAgent |
Discrete action space |
ContinuousPPOAgent |
Continuous action space |
Key Methods
Agent.act(state) → (action, log_prob) or (action, log_prob, raw_action)
Agent.act_deterministic(state) → Deterministic action (for evaluation)
Agent.train(num_epochs=4, batch_size=64) → Train on trajectory
Agent.store(packet) → Add transition to trajectory
Agent.clear() → Clear trajectory buffer
Agent.save(path) → Save checkpoint
Agent.load(path) → Load checkpoint
Configuration
agent = DiscretePPOAgent(
state_dim=4, action_dim=2,
architecture={ # Custom network architecture
"actor": [state_dim, 64, 64, action_dim],
"critic": [state_dim, 64, 64, 1]
},
lr=3e-4, gamma=0.99,
gae_lambda=0.95, epsilon=0.2,
critic_coef=0.5, entropy_coef=0.01,
num_envs=1, trajectory_size=2048,
device="cpu"
)
License
MIT
Metadata
Release files for ezppo 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ezppo-0.0.0.tar.gz | 13.8 kB | With provenance | Details for ezppo-0.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ezppo-0.0.0-py3-none-any.whl | Python 3 | none | any | Details for ezppo-0.0.0-py3-none-any.whl |
Total release size: 23.7 kB
Release files / ezppo-0.0.0.tar.gz
| Download URL | ezppo-0.0.0.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b240ee640860bf917890619de01fedca28f3d39b0a5510ada14025ba5960106
|
|
BLAKE2b-256 checksum How to use checksums |
2542cab05d5b32bafa0b6dbcecca68cb43e8d1d2a536d3083e11fad099e940b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / ezppo-0.0.0-py3-none-any.whl
| Download URL | ezppo-0.0.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
394e6b4412fa676cdf574352835a951a99ae31a8edf74535d55d407bd589df31
|
|
BLAKE2b-256 checksum How to use checksums |
2502a714e175307f15585b2fc3ccedd054ce54789bbb78e105f47f0502c7bd00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for ezppo 0.0.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ezppo-0.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA 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.