Skip to main content

A Liquid Reinforcement Learning (RL) framework.

Project description

Logo

codecov Python Version License Issues

Found on:

Velora

Velora is a lightweight and extensible framework built on top of powerful libraries like Gymnasium and PyTorch, specializing in a unique approach to Deep Reinforcement Learning (RL) algorithms, a paradigm we call Liquid RL.

Instead of Fully-connected Networks, Velora combines Liquid Neural Networks (LNNs) with Neural Circuit Policies (NCPs), specifically Ordinary Neural Circuits (ONCs).

These two components have interesting benefits:

  • LNNs are a powerful RNN architecture that learns system dynamics, not just data patterns.
  • NCPs focus on sparsely connected neurons with distinct functions, mimicking biological behaviour.

From what we've seen, these networks are powerful, small-scale architectures that excel in model explainability, making them perfect for control tasks.

Velora offers Liquidfied PyTorch-based implementations of RL algorithms, designed to be intuitive, easy to use, and customizable.

In other frameworks, we've seen a trend of heavy abstraction in favour of minimal lines of code. Our approach aims to offer a best of both worlds, abstracting code away but making the details explainable on the backend, while giving you the freedom to customize as needed.

To get started, simply install it through pip:

pip install velora

Here's a simple example that should work 'as is':

from functools import partial

from velora.models import LiquidDDPG
from velora.gym import wrap_gym_env
from velora.utils import set_device, set_seed

import gymnasium as gym
from gymnasium.wrappers import NormalizeObservation, NormalizeReward, ClipReward

# Setup reproducibility and PyTorch device
seed = 64
set_seed(seed)

device = set_device()

# Add extra wrappers to our environment
env = wrap_gym_env("InvertedPendulum-v5", [
    partial(NormalizeObservation, epsilon=1e-8),
    partial(NormalizeReward, gamma=0.99, epsilon=1e-8),
    partial(ClipReward, max_reward=10.0),
    # RecordEpisodeStatistics,  # Applied automatically!
    # partial(NumpyToTorch, device=device),  # Applied automatically!
])

# Or, use the standard gym API (recommended for this env)
env = gym.make("InvertedPendulum-v5")

# Set core variables
state_dim = env.observation_space.shape[0]  # in features
n_neurons = 20  # decision/hidden nodes
action_dim = env.action_space.shape[0]  # out features

buffer_size = 100_000
batch_size = 128

# Train a model
model = LiquidDDPG(
    state_dim, 
    n_neurons, 
    action_dim, 
    buffer_size=buffer_size,
    device=device,
)
metrics = model.train(env, batch_size, n_episodes=300)

Currently, the framework only supports Gymnasium environments and will likely stay that way.

API Structure

The frameworks API is designed to be simple and intuitive. We've broken into two main categories: core and extras.

Core

The primary building blocks you'll use regularly.

from velora.models import [algorithm]

Extras

Utility methods that you may use occasionally.

from velora.gym import [method]
from velora.utils import [method]

Customization

Customization is at the heart of Velora but requires a deeper understanding of the API.

You can read more about it in the documentation tutorials.

Active Development

🚧 View the Roadmap 🚧

Velora is a tool that is continuously being developed. There's still a lot to do to make it a fully functioning framework, such as detailed API documentation, and more RL algorithms.

Our goal is to provide a quality open-source product that works 'out-of-the-box' that everyone can experiment with, and then gradually fix unexpected bugs and introduce more features on the road to a v1 release.

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

velora-0.0.2.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

velora-0.0.2-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file velora-0.0.2.tar.gz.

File metadata

  • Download URL: velora-0.0.2.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.4 Windows/10

File hashes

Hashes for velora-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0eafc23d7165c341bce413f053122da617fec8612ffbbe5f46851066a0149d02
MD5 9ceb750f20e409ca3290f8b824c66ca9
BLAKE2b-256 653f87cc2c572e932ec7a9ce63d180d6f789accb8cefb2a2c090744f1278b85f

See more details on using hashes here.

File details

Details for the file velora-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: velora-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.4 Windows/10

File hashes

Hashes for velora-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c98a829bab9cbdec72cf73dddb5a24f9eeda845720517f6aa1ce104030a9e8ab
MD5 20a96dab3b57764cf83f0039df94cc47
BLAKE2b-256 1a30d552188e564c4f0f3a85e46b8b1eda00f9a12612466e9b3c33aa5430e965

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