prob-spaces: Probability Distributions from Gymnasium Spaces
prob-spaces is a Python package that allows you to create probability distributions from Gymnasium spaces.
It provides a simple and intuitive interface for working with various probability spaces in reinforcement learning
environments.
Key Features:
- Create probability distributions directly from Gymnasium spaces
- Support for common space types: Discrete, MultiDiscrete, Box, and Dict
- Seamless integration with PyTorch for sampling and computing log probabilities
- Support for masking operations to constrain valid actions
Installation
From PyPI
To install prob-spaces from PyPI:
pip install prob-spaces
GPU Support
prob-spaces uses PyTorch, which can be installed with CUDA support for GPU acceleration. The package configuration includes a PyTorch CUDA 12.4 index. To use a different CUDA version, you may need to modify the PyTorch installation separately.
Example Usage
Here's a simple example of how to use prob-spaces:
import gymnasium as gym
import torch as th
from prob_spaces.converter import convert_to_prob_space
# Create a Gymnasium space
action_space = gym.spaces.Discrete(5)
# Convert to a probability space
prob_space = convert_to_prob_space(action_space)
# Create a probability distribution
probs = th.ones(5) # Uniform distribution
dist = prob_space(probs)
# Sample from the distribution
action = dist.sample()
# Compute log probability
log_prob = dist.log_prob(action)
Documentation
Documentation is available online and provides detailed information on how to use the package, including examples and API references.
Release files for prob-spaces 0.1.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 | |
|---|---|---|---|
| prob_spaces-0.1.0.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prob_spaces-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / prob_spaces-0.1.0.tar.gz
| Download URL | prob_spaces-0.1.0.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4b185b2c1d46bb3f95d93a9300ab7fd545bd7e4db97254086a1a09cf74547fd
|
|
BLAKE2b-256 checksum How to use checksums |
f61840c84b48172bbb2741b92b9f06810f5e3aa255c35aca91c19c21fdd3667f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|
Release files / prob_spaces-0.1.0-py3-none-any.whl
| Download URL | prob_spaces-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
beeffc667036d018dcd0b374bcae4712bb2c836aac275e65c4ba5bbe1a8894fa
|
|
BLAKE2b-256 checksum How to use checksums |
f2327694ab073c7e79408350ffb4e49519791a85e0c51f5bd018ec478e527e01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|