Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nearai/torchfold
Tools for PyTorch
https://github.com/nearai/torchfold
deep-learning deep-neural-networks machine-learning pytorch
Last synced: 3 days ago
JSON representation
Tools for PyTorch
- Host: GitHub
- URL: https://github.com/nearai/torchfold
- Owner: nearai
- License: apache-2.0
- Created: 2017-08-22T22:28:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-10T20:26:14.000Z (over 2 years ago)
- Last Synced: 2024-05-23T06:48:01.224Z (7 months ago)
- Topics: deep-learning, deep-neural-networks, machine-learning, pytorch
- Language: Python
- Size: 73.2 KB
- Stars: 221
- Watchers: 17
- Forks: 28
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-pytorch-list-CNVersion - pytorch-tools
README
[![PyPi version](https://pypip.in/v/torchfold/badge.png)](https://pypi.org/project/torchfold/) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1299387.svg)](https://doi.org/10.5281/zenodo.1299387)
# TorchFoldBlog post: http://near.ai/articles/2017-09-06-PyTorch-Dynamic-Batching/
Analogous to [TensorFlow Fold](https://github.com/tensorflow/fold), implements dynamic batching with super simple interface.
Replace every direct call in your computation to nn module with `f.add('function name', arguments)`.
It will construct an optimized version of computation and on `f.apply` will dynamically batch and execute the computation on given nn module.## Installation
We recommend using pip package manager:
```
pip install torchfold
```## Example
```
f = torchfold.Fold()
def dfs(node):
if is_leaf(node):
return f.add('leaf', node)
else:
prev = f.add('init')
for child in children(node):
prev = f.add('child', prev, child)
return prevclass Model(nn.Module):
def __init__(self, ...):
...def leaf(self, leaf):
...def child(self, prev, child):
...res = dfs(my_tree)
model = Model(...)
f.apply(model, [[res]])
```To cite this repository in publications:
@misc{illia_polosukhin_2018_1299387,
author = {Illia Polosukhin and
Maksym Zavershynskyi},
title = {nearai/torchfold: v0.1.0},
month = jun,
year = 2018,
doi = {10.5281/zenodo.1299387},
url = {https://doi.org/10.5281/zenodo.1299387}
}