No project description provided
Project description
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.
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 prob_spaces-0.0.2b0.tar.gz.
File metadata
- Download URL: prob_spaces-0.0.2b0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a60256d858cd6c7c7a205bbca5372fb4e2fe0de86f6cdba3d62a1a073dcbe229
|
|
| MD5 |
6b796aa686f8936c386f9b44ee386ea0
|
|
| BLAKE2b-256 |
65957759093ef9c8870576b245bdbbecd1f7c3136c86b68a86a2313cd82253f8
|
File details
Details for the file prob_spaces-0.0.2b0-py3-none-any.whl.
File metadata
- Download URL: prob_spaces-0.0.2b0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
397d2866f23247cc4539f8699157253955be821827d2de36548611ee40976c9b
|
|
| MD5 |
7e08d9e6420e2e950115ab5e5b283e3f
|
|
| BLAKE2b-256 |
b9820d1788568ad133d70afe42c44b8403e323c7cfb9a3aa79ceb96677632dfc
|