pytorch / tnt

A lightweight library for PyTorch training tools and utilities
https://pytorch.org/tnt/
Other
1.66k stars 271 forks source link

BatchDataset cannot handle arguments from tuple #16

Closed escorciav closed 2 years ago

escorciav commented 7 years ago

Hi,

I tried to use BatchDataset to concatenate the outputs, tuple with features, labels, etc., from my dataset but it seems that I should pack them inside a dictionary otherwise, this line will produce an error. It would be cool to say that in the documentation or provide support for iterable like tuple and list.

P.D. Thanks for providing this awesome set of tools.

RicherMans commented 7 years ago

As a small code example:

import torchnet as tnt
import torch

f = []
t = []
for i in xrange(100):
    f.append(torch.randn(20))
    t.append(torch.randn(1))
b = tnt.dataset.TensorDataset([f,t])
seta = tnt.dataset.BatchDataset(b, 2)
for k,v in seta:
    print k,v

This will fail in the line above mentioned.