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 Last Commit 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.1.0.tar.gz (7.3 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.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file prob_spaces-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for prob_spaces-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4b185b2c1d46bb3f95d93a9300ab7fd545bd7e4db97254086a1a09cf74547fd
MD5 82cd0ae8ed53534e457039bdc09a2adf
BLAKE2b-256 f61840c84b48172bbb2741b92b9f06810f5e3aa255c35aca91c19c21fdd3667f

See more details on using hashes here.

File details

Details for the file prob_spaces-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prob_spaces-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 beeffc667036d018dcd0b374bcae4712bb2c836aac275e65c4ba5bbe1a8894fa
MD5 a07cef22e6cdd56debc535f5c1223bc4
BLAKE2b-256 f2327694ab073c7e79408350ffb4e49519791a85e0c51f5bd018ec478e527e01

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