Giter VIP home page Giter VIP logo

embodied's Introduction

PyPI   Docs

Embodied

Fast reinforcement learning research.

Overview

The goal of Embodied is to empower researchers to quickly implement new agents at scale. Embodied achieves this by specifying an interface both for environments and agents, allowing users to mix and match agents, envs, and evaluation protocols. Embodied provides common building blocks that users are encouraged to fork when more control is needed. The only dependency is Numpy and agents can be implemented in any framework.

Packages

embodied/
  core/    # Config, logging, checkpointing, simulation, wrappers
  run/     # Evaluation protocols that combine agents and environments
  envs/    # Environment suites such as Gym, Atari, DMC, Crafter
  agents/  # Agent implementations

Agent API

class Agent:
  __init__(obs_space, act_space, config)
  policy(obs, state=None, mode='train') -> act, state
  train(data, state=None) -> state, metrics
  report(data) -> metrics
  dataset(generator) -> generator
  init_policy(batch_size) -> state
  init_train(batch_size) -> state

Env API

class Env:
  __len__() -> int
  @obs_space -> dict of spaces
  @act_space -> dict of spaces
  step(action) -> obs dict
  render() -> array
  close()

embodied's People

Contributors

danijar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

embodied's Issues

Explore as behavior for dreamerv3

Hi,

  1. expl.py was copied from /dreamerv3 repo but nets.Input have new constructor now.
    In lines 16, 17: next part need to be removed as it case exception:
    , dims='deter'

  2. In file behaviors.py was added reward scale, line 86.
    But it also comes to self.rewards so in line 102:
    mets = rewfn.train(data)
    it throw exeption as lambda result not have .train method
    To fix that need to move self.rewards[key] = rewfn before lambda cover or use another variable name for lambda scale

  3. Verry cool change for act_space flow (multy action is top) but they make some "critical" issue for Explore:
    I have simple env with act_space:
    {'action': Space(dtype=int32, shape=(), low=0, high=15), 'reset': Space(dtype=bool, shape=(), low=False, high=True)}

In new act_space flow not present anymore OneHotAction wraper.
MLP for expl.Disag got dimension on construct (expl.py line 18):
[deter] + [stoch] + [action]
In my case its like:
Traced<ShapedArray(float16[32,31,1537])>with<DynamicJaxprTrace(level=1/0)>

But on loss calculation in train, action was converted to list length=15 and MLP got call like:
Traced<ShapedArray(float16[16,1024,1551])>with<DynamicJaxprTrace(level=1/0)>

So throw exeception:
TypeError: dot_general requires contracting dimensions to have the same shape, got (1551,) and (1537,).
in nets.py, line 563

For now as fix I just turn off [action] in disag_head.inputs but not sure how critical it change behavior.

With Best Regards,
Yaroslav

pip install embodied

Hi,

this command can't be executed correctly as in setup.py present line:
'dreamerv3': parse_reqs('embodied/agents/dreamerv3/requirements.txt'),

but both agents not included into package tar.gz

When you will build next version - please fix that.

Thank you.

Windows compatibility

I got the following error when installing through pip on windows 11:

Collecting embodied
  Using cached embodied-1.0.2.tar.gz (45 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\nickdv\AppData\Local\Temp\pip-install-dvx6q8ps\embodied_295f71e2acbf47f6885e32bcd7fa7bd6\setup.py", line 32, in <module>
          'dreamerv3': parse_reqs('embodied/agents/dreamerv3/requirements.txt'),
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\nickdv\AppData\Local\Temp\pip-install-dvx6q8ps\embodied_295f71e2acbf47f6885e32bcd7fa7bd6\setup.py", line 8, in parse_reqs
          requirements = requirements.read_text().split('\n')
                         ^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\nickdv\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 1058, in read_text
          with self.open(mode='r', encoding=encoding, errors=errors) as f:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\nickdv\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 1044, in open
          return io.open(self, mode, buffering, encoding, errors, newline)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [Errno 2] No such file or directory: 'embodied\\agents\\dreamerv3\\requirements.txt'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I had to change the setup.py to make it compatible with windows.
I had to get rid of the pathlib dependency and change it to os.
I did the following:

Clone the repository and change the setup.py to

 import os
import re
import setuptools

def parse_reqs(filename):
    with open(filename, 'r', encoding='utf-8') as file:
        requirements = file.read().split('\n')
    requirements = [x for x in requirements if x.strip()]
    return requirements

def parse_version(filename):
    base_path = os.path.dirname(__file__)
    full_path = os.path.join(base_path, filename)
    with open(full_path, 'r', encoding='utf-8') as file:
        text = file.read()
    version = re.search(r"__version__ = '(.*)'", text).group(1)
    return version

with open('README.md', 'r', encoding='utf-8') as file:
    long_description = file.read()

setuptools.setup(
    name='embodied',
    version=parse_version('embodied/__init__.py'),
    author='Danijar Hafner',
    author_email='[email protected]',
    description='Fast reinforcement learning research',
    url='http://github.com/danijar/embodied',
    long_description=long_description,
    long_description_content_type='text/markdown',
    packages=setuptools.find_packages(),
    include_package_data=True,
    install_requires=parse_reqs('embodied/requirements.txt'),
    extras_require={
        'dreamerv3': parse_reqs('embodied/agents/dreamerv3/requirements.txt'),
    },
    classifiers=[
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 3',
        'Topic :: Scientific/Engineering :: Artificial Intelligence',
    ],
)

Then in the directory of the cloned repository, open a terminal and run python setup.py install to install the dependency.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.