hughperkins / pytorch

Python wrappers for torch and lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding support for lists and tuples in data

soravux opened this issue · comments

I am currently using PyTorch to train a neural network using two heads, like the one explained on this thread. Basically, the output of the network is a nn.ConcatTable() and the criterion is a nn.ParallelCriterion().

This requires a table for its labels, containing as many tensors as there are "heads" on the network.

In PyTorch, I would have guessed it needed a list of Numpy arrays, but pushSomething() in PyTorchAug.py complains about not knowing Python tuples and lists.

I have worked around this by creating a dictionary and attributing the values 1, 2, 3, etc. to as the keys of each numpy array. I believe this is how Lua tables work under the hood. It would not be hard to add this implementation directly into PyTorch.

Are you interested in a Pull Request adding support for lists and tuples (implementing them as dictionaries with incrementing keys)? I can have it ready soon, if you wish.

By the way, thanks a lot for developing this useful project!

Are you interested in a Pull Request adding support for lists and tuples (implementing them as dictionaries with incrementing keys)? I can have it ready soon, if you wish.

Sounds good :-)

PR in #13. Let's discuss over there.