vzhong / chainer2pytorch

Converts Chainer modules to PyTorch, parameters included.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chainer2pytorch

chainer2pytorch implements conversions from Chainer modules to PyTorch modules, setting parameters of each modules such that one can port over models on a module basis.

Installation:

pip install git+git://github.com/vzhong/chainer2pytorch.git

Usage:

from tc import nn
from chainer import links as L

c = L.Linear(10, 50)
t = nn.Linear.from_chainer(c)

c = L.NStepLSTM(1, 10, 20, 0)
t = nn.LSTM.from_chainer(c)

Note that when do you a forward call, PyTorch's LSTM only gives the output of the last layer, whereas chainer gives the output of all layers.

Test:

nosetests tests

Pull requests are welcome!

About

Converts Chainer modules to PyTorch, parameters included.

License:MIT License


Languages

Language:Python 100.0%