Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sannidhi_gae_returns_20251112-0.0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sannidhi_gae_returns_20251112-0.0.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file sannidhi_gae_returns_20251112-0.0.1.tar.gz.

File metadata

File hashes

Hashes for sannidhi_gae_returns_20251112-0.0.1.tar.gz
Algorithm Hash digest
SHA256 88956e95d86e0761c6bb4d59bc3340132c75c1c893e849183caaeef70f05265c
MD5 73ae4b07c0542c94b6e0b168fb247de5
BLAKE2b-256 e0163172f2d7534f09d25ab5a965f35190332eba7a0943d79a1ef5cfe9ba278f

See more details on using hashes here.

File details

Details for the file sannidhi_gae_returns_20251112-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sannidhi_gae_returns_20251112-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c99c35b671bbaee443b682e668701562aefa506bd85d2dfb915c39713b53a3d5
MD5 82cd37d504b8956535828b2c165580bc
BLAKE2b-256 a2bc4e81b1e84b89b99a8e2880892489a872b57b0f65d79fa63fd84646d00997

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page