Skip to main content

A package for creating IL datasets

Project description

IL Datasets

Hi, welcome to the Imitation Learning (IL) Datasets. Something that always bothered me a lot was how difficult it was to find good weights for an expert, or trying to create a dataset for different state-of-the-art methods. For this reason I've created this repository in an effort to make it more accessible for researches to create datasets using experts from the Hugging Face.


How does it work?

This project also works with multithreading, which should accelerate the dataset creation. It consists of one Controller class, which requires two different functions to work: (i) a enjoy function (for the agent to play and record an episode); and a (ii) collate function (for putting all episodes together).


The enjoy function will receive 3 parameters and return 1:

  • path: str - where the episode is going to be recorded

  • experiment: Context - A class for recording all information (if you don't want to use print - keeping the console clear)

  • expert: Policy - A model based on the StableBaselines3 BaseAlgorithm.

  • returns: bool - Whether it was successfull or not

Obs: To use the model you can call predict, the policy class already has the correct form of using it (a.k.a., how the StableBaselines3 uses).


The collate function will receive 2 parameters and return 1:

  • path: str - where it should save the final dataset

  • episodes: list[str] - A list of paths for each file

  • returns: bool - Whether it was successfull or not


Requirements

I did use Python=3.9 during development.
All other requirements are listed in requirements.txt.


Registering new experts

If you would like to add new experts locally, you can call the Experts class. It uses the following structure:

  • identifier: str - A name for calling the expert.
  • policy: Policy - A dataclass with:
    • name: str - Gym Environment name
    • repo_id: str - Hugging Face repo indentification
    • filename: str - Weights file name
    • threshold: float - How much reward should the episode accumulate to be considered good
    • algo: BaseAlgorithm - The class from StableBaselines3

Obs: If not using StableBaselines, the expert has to have a predict function that receives:

  • obs: Tensor - Current environment state
  • state: Tensor - Model's internal state
  • deterministic: bool - If it should explore or not

This repository is in development

Here is a list of the upcoming releases:

  • Collate function support
  • Support for installing as a dependency
  • Module for downloading trajectories from a Hugging Face dataset
    • Create benchmark for data
  • Create actual documentation
  • Create some examples
  • Create tests
  • Create GitHub workflow with pylint

If you like this repository be sure to check my other projects:

Development

Academic

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

il-datasets-0.3.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

il_datasets-0.3.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file il-datasets-0.3.0.tar.gz.

File metadata

  • Download URL: il-datasets-0.3.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for il-datasets-0.3.0.tar.gz
Algorithm Hash digest
SHA256 096dbbb23819dc0a0be2d6d25531f1f98b96f1de50c754db91cf750f32b4bead
MD5 146482025b887ce0ba3caa2714fda7d6
BLAKE2b-256 f0a7e7898c5db64e258a4703bba25470ae493095ec28be5b2d7fbe6b3363a58f

See more details on using hashes here.

File details

Details for the file il_datasets-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: il_datasets-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for il_datasets-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25bf83711913b243cc94e45f6703d343b8ee5eddc348c4627996da01e218a44b
MD5 47c3abd61e9c9205e7438c34888dcf71
BLAKE2b-256 81c4c0d38f5d2e66764525c371b4841a03a82a46e179587f851e411afe91927a

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