Discounted returns utilities for Reinforcement Learning: discounted cumulative sums, n-step TD targets, and Generalized Advantage Estimation (GAE). Created by Sannidhi Nair for B.Tech AI (RL Practicum, NMIMS MPSTME).
Project description
GAE & Returns
Tiny, dependency-free utilities to compute:
- Discounted cumulative returns
- n-step TD target
- Generalized Advantage Estimation (GAE)
Usage
from gae_returns import discounted_cumsum, n_step_target, gae
r = [1.0, 0.0, -1.0]
print(discounted_cumsum(r, gamma=0.9)) # -> [1.0 + 0.9*0 + 0.9^2*(-1), ...]
# n-step target for step t with bootstrap V_{t+n}
print(n_step_target(rewards=[1.0, 0.5], gamma=0.99, bootstrap_value=0.2))
# GAE given rewards and state values
rewards = [1.0, 0.0, 0.5]
values = [0.2, 0.3, 0.4, 0.0] # note extra terminal value V_T
adv, ret = gae(rewards, values, gamma=0.99, lam=0.95)
Install
pip install sannidhi-gae-returns-20251112
Testing
pip install pytest
pytest -q
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sannidhi_gae_returns_20251112-0.0.1.tar.gz.
File metadata
- Download URL: sannidhi_gae_returns_20251112-0.0.1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88956e95d86e0761c6bb4d59bc3340132c75c1c893e849183caaeef70f05265c
|
|
| MD5 |
73ae4b07c0542c94b6e0b168fb247de5
|
|
| BLAKE2b-256 |
e0163172f2d7534f09d25ab5a965f35190332eba7a0943d79a1ef5cfe9ba278f
|
File details
Details for the file sannidhi_gae_returns_20251112-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sannidhi_gae_returns_20251112-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c99c35b671bbaee443b682e668701562aefa506bd85d2dfb915c39713b53a3d5
|
|
| MD5 |
82cd37d504b8956535828b2c165580bc
|
|
| BLAKE2b-256 |
a2bc4e81b1e84b89b99a8e2880892489a872b57b0f65d79fa63fd84646d00997
|