Hi, inside a Jupyter notebook, I made a little utility to send tuples to a model.
class SequenceDataset(Dataset):
r"""Dataset wrapping Sequences (indexable and iterable).
Each sample will be retrieved by indexing along the first dimension,
tupled together.
Arguments:
*seqs: sequences that have the same length.
"""
def __init__(self, seqs):
assert all([len(seqs[0]) == len(s) for s in seqs])
self.seqs = seqs
def __getitem__(self, index):
return tuple(s[index] for s in self.seqs)
def __len__(self):
return len(self.seqs[0])
The problem is that after from fastai2.vision.all import *
, Python’s built-in all function is interpreted as a reference to fastai2’s all.py module. Then assert all(...)
fails.
I worked around it by del all
. But what is the best practice to deal with this particular situation and in general?
Thanks!