Skip to main content

No project description provided

Project description

prob-spaces: Probability Distributions from Gymnasium Spaces

PyPI - Python Version version License OS OS OS Tests Code Checks codecov Ruff

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


Download files

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

Source Distribution

prob_spaces-0.0.3b0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

prob_spaces-0.0.3b0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file prob_spaces-0.0.3b0.tar.gz.

File metadata

  • Download URL: prob_spaces-0.0.3b0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for prob_spaces-0.0.3b0.tar.gz
Algorithm Hash digest
SHA256 13d67a0b0c9283b6c48407f452dd7925715d1adc48ed81467942e890872cd7b3
MD5 34602ab67b8fb37fc2c860e009a5f5fb
BLAKE2b-256 1ea38d8393c2f0d25759d0f8326fd08312f7a3d1e62368528b422b30045796f6

See more details on using hashes here.

File details

Details for the file prob_spaces-0.0.3b0-py3-none-any.whl.

File metadata

File hashes

Hashes for prob_spaces-0.0.3b0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b0f545ca18bf5808c240094d4bebc864c2f74727c5467af18f7eb751eec406f
MD5 60d1552afab68163566231d53ccbb82f
BLAKE2b-256 364b9e12501ba481f630f44efefb2ee4591fe906297624832dc6fc12afca922b

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