mean-conc-beta
Beta distribution parameterized by mean and concentration for bounded continuous action spaces in reinforcement learning.
Install
$ pip install mean-conc-beta
Usage
import torch
from mean_conc_beta import Beta
# pass the bounds of the action space
beta = Beta(bounds = (-2., 2.))
# network output: (batch, num_actions, 2) for raw mean and concentration
params = torch.randn(16, 4, 2, requires_grad = True)
# distribution on the action bounds
dist = beta(params)
# sample actions
actions = dist.sample()
actions_reparam = dist.rsample()
# joint log prob and entropy over the action dimensions
log_prob = dist.log_prob(actions).sum(dim = -1)
entropy = dist.entropy().sum(dim = -1)
# auto-rescale actions directly into env.step, with optional clipping
env_step = beta.rescale_env_step(env.step, target_range = (-2.1, 2.1), clip = (-2., 2.))
next_obs, reward, term, trunc, info = env_step(actions)
# behavior cloning with mse loss on mean
expert_actions = torch.rand(16, 4) * 4. - 2.
pred_mean = beta.mean(params)
bc_loss = (pred_mean - expert_actions).pow(2).mean()
bc_loss.backward()
Citations
@article{Ferrari2004BetaRF,
title = {Beta Regression for Modelling Rates and Proportions},
author = {Silvia L. P. Ferrari and Francisco Cribari-Neto},
journal = {Journal of Applied Statistics},
year = {2004},
volume = {31},
pages = {799 - 815}
}
@inproceedings{Chou2017TheBP,
title = {The Beta Policy for Continuous Reinforcement Learning},
author = {Po-Wei Chou and Daniel Maturana and Sebastian Scherer},
booktitle = {International Conference on Machine Learning},
year = {2017}
}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mean_conc_beta-0.0.9.tar.gz
(7.2 kB
view details)
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 mean_conc_beta-0.0.9.tar.gz.
File metadata
- Download URL: mean_conc_beta-0.0.9.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93dfe9e199f43892701221c69d38c731eabcfbe5e88eb1133a4dbcd0c2bf5361
|
|
| MD5 |
2bce14abe41f691f4b44e324f33a3aca
|
|
| BLAKE2b-256 |
298d236fce55ab7b9322c2c705a7a77c865fd7dcc733359c16d321e63165b4cb
|
File details
Details for the file mean_conc_beta-0.0.9-py3-none-any.whl.
File metadata
- Download URL: mean_conc_beta-0.0.9-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47588629fc031f73877d8a94eb7e087543a616212229ae1520f0fa68ad67ba01
|
|
| MD5 |
4a3707396c780c5a967bc2c5c56586a1
|
|
| BLAKE2b-256 |
34eb887f40456752bafbcf0f1aa2f853cfce6ef606a82cc59d52eff43e47f182
|