A PyTorch-powered python toolbox to train deep neural networks to perform motor tasks.
Project description
MotorNet
This repository contains MotorNet, a python package that allows training recurrent neural networks to control for biomechanically realistic effectors. This toolbox is designed to meet several goals:
- No hard dependencies beyond typically available python packages. This should make it easier to run this package on remote computing units.
- Provide users with a variety of muscle types to chose from.
- Flexibility in creating new, arbitrary muscle wrappings around the skeleton, to enable fast exploration of different potential effectors and how to control them. The moment arm are calculated online according to the geometry of the skeleton and the (user-defined) paths of the muscles.
- User-friendly API, to allow for easier familiarization and intuitive usage. We want to enable a focus on ideas, not implementation. The toolbox focuses on subclassing to allow users to implement their custom task designs, custom plants, and custom controller networks.
- Open-source, to allow for user contribution and community-driven incremental progress.
State of the project
The package is feature complete, and is used by several people to progress in their research. We are currently in beta phase, meaning the toolbox is publicly available but we are still on the lookout for potential bugs and fixes to apply. Please feel free to log an issue if you think you found a bug, we appreciate any contribution. Stay tuned for more!
An online documentation is available. Feel free to check it out.
How to Install
Install from source
To install the latest development release, you can install directly from GitHub's repository. This will install version 0.2.0, which relies on PyTorch instead of TensorFlow. Please see the changelog for more details on the difference between the current development release and the PyPI release.
pip install git+https://github.com/OlivierCodol/MotorNet.git@pytorch
Please see the staged changes at the bottom of this file to see the changes currently implemented on this branch.
Install with pip
NOTE: The current PyPI version of motornet is 0.1.5, which relies on TensorFlow
First, please make sure that the latest pip version is installed in your working environment.
python3 -m pip install -U pip
Then you can install motornet using a simple pip install command.
python3 -m pip install motornet
Install with Anaconda
Installation via Anaconda is currently not supported.
Requirements
There is no third-party software required to run MotorNet. However, some freely available python dependencies are required.
If you are running the current development release (version 0.2.0), the requirements are as follows.
- PyTorch: MotorNet relies on PyTorch to create tensors and build the graph.
- NumPy: For array and matrix computations when not using tensors.
- Gymnasium:
motornetenvironments are child classes ofgymnasiumenvironments. - Matplotlib: For plotting utilities, mainly in the plotor module.
If you are running the current PyPI release (version 0.1.5), which relies on TensorFlow, the requirements are as follows.
- TensorFlow: MotorNet is first and foremost built on TensorFlow. However, the standard
TensorFlow toolbox is not compatible with recent Apple machines equipped with M1 silicon chips, and users must rely on
an adapted version called tensorflow-macos. When installing MotorNet, the
setup.pyroutine will automatically check the machine's OS platform and hardware to assess whether to solve for thetensorflowortensorflow-macosdependency. - NumPy: For array and matrix computations when not using tensors.
- Matplotlib: For plotting utilities, mainly in the plotor module.
- IPython: Mainly for callbacks that output training metrics during model training.
- joblib: For parallelization routines in the parallelizer script.
Tutorials
There are several tutorials available to get you started, available in the repository's examples folder, as well as on the documentation website. Hopefully they will give a sense of how the API is supposed to work.
Tutorials and API documentation for version 0.1.5 are still available on the website and GitHib repository for those who wish to consult them. They will remain available for the foreseeable future.
Changelog
See here for a curated log of update contents [Note: This will redirect to the main branch's changelog].
Version 0.2.0 - Staged changes
First and foremost, this update moves motornet from tensorflow to pytorch. There has been systematic requests for
a pytorch implementation of this package, and over time it is becoming clear that this will enable better integration
with existing research efforts from the scientific community that this package is aiming to help. As a consequence,
many API changes and change in the code structure were made, as the logical structure of pytorch is fundamentally
different than that of tensorflow. These changes are further detailed below.
-
Renamed the
motornet.plantspackage toeffectorand themotornet.plants.Plantclass toEffector, as 'plant' is a specific engineering term and may be overly arcanic to a more general audience. Generally, the swap from "plant" to "effector" has been enacted consistently in the text and code. -
Taskobject essentially perform computations pertaining toenvironmentobjects in typical simulation software for machine learning. Therefore, themotornet.tasksmodule has been renamedmotornet.environmentand theTaskbase class has been renamed toEnvironment. This is also now a subclass of gymnasium's gymnasium.Env class, and it shares its API convention. The motivation behind these changes is thatgymnasiumis a popular interfacing package for simulation environments in machine learning, and standardizingmotornet's API according togymnasiumwill enable wider cross-compatibility, as well as facilitate familiarization efforts from a lot of researchers already accustomed togymnasium's API. Users are strongly encouraged to check the updated tutorial notebooks onmotornet's GitHub repository and on the online documentation website for more detailed explanation of the newEnvironmentAPI, if they are not alredy familiar withgymnasium. Generally, the swap from "task" to "environment" has been enacted consistently in the text and code. -
Pytorchdoes not require the creation of end-to-endmodelobjects astensorflowdoes. Consequently,motornetpipelines only require setting up anEffectorand wrapping it up in anEnvironmentobject, without having to create aNetworkobject at all. Feedback delays and Gaussian noise are now handled directly by theEnvironmentclass. -
Removed all sub-packages in
motornet. Thepytorchimplementation allows users to create their own loss and network objects the way they typically would for any project beyondmotornet, removing the need for a complex sub-packaging structure differentiating between set of modules falling under thenetsoreffectorscategory. Therefore,motornetnow only contains modules. For instance, themotornet.effector.muscle.Muscleclass is now directly accessible asmotornet.muscle.Muscle. -
The
motornet.plotor.plot_pos_over_time()function now takes cartesian position as argument rather than full cartesian states that include positions and velocities. In practice, the velocities were always discarded by that function so we removed this step to allow for a more transparent and intuitive function syntax. -
The
muscle_typeargument of themotornet.effector.Effectorclass has been renamed tomusclefor conciseness. -
The term
excitationis now replaced byactionto better match the terminology in place in continuous control machine learning. Note thatactionandactivationare not the same variables. -
Added a
motornet.effector.muscles.MujocoHillMuscleclass to themusclemodule. This object instantiates MuJoCo's Hill-type muscle as described in the MuJoCo documentation. -
The
motornet.utils.parallelizer.pyfile has been removed, as the means of streamlining model training pipelines usually boils down to personal preference. -
Users can now seed their
EnvironmentandEffectorclasses. Seeding is an important aspect of reproducible programming, and is usually considered a "best practice". Since theEnvironmentandEffectorclasses are the only classes that make use of a random generator, these are the only classes that currently require seeding inmotornet. -
All
motornetobjects now inherit from thetorch.nn.Moduleclass. Amongst other things, this allows easy device assignment for model parameters, usingpytorch's usual.to(device)method. -
Renamed the
muscles,skeletons,effectors, andenvironmentsmodules tomuscle,skeleton,effector, andenvironmentfor conciseness.
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
File details
Details for the file motornet-0.2.0.tar.gz.
File metadata
- Download URL: motornet-0.2.0.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d972085adab86ea8df838cf03fd4bd25ab0c5f155443a8e2307afbd55ea1c7e
|
|
| MD5 |
a231afd1379ed0c152d937ca97859ed3
|
|
| BLAKE2b-256 |
d062040c01b208e81175634030bb26af8e4da6103bcb2f18d1cbf4acdb344a95
|