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.4b0.tar.gz (7.0 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.4b0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for prob_spaces-0.0.4b0.tar.gz
Algorithm Hash digest
SHA256 5982f69e244dcc39c524a0e8d769d8ad3bef1283f17b35542b44c37b28b55e96
MD5 73ceaf932319c7681ce8d3df2e5d6d8c
BLAKE2b-256 8fe6657c03ca6480b29d8087072045e5becbf9c01e6c6bcb067bec772ed7b92f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prob_spaces-0.0.4b0-py3-none-any.whl
Algorithm Hash digest
SHA256 288b3f97e728b84d6e4c1e98bdd51ef75a85d4ca6c4ebf85bc259d87c40bdfe2
MD5 965afed5cfd04563f30c34fff4910928
BLAKE2b-256 0de546bf9c245214404b8e284d635edacb0735cc77f65ccd92a848f7c9cffd3e

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