NVIDIA / sentiment-discovery

Unsupervised Language Modeling at scale for robust sentiment classification
Other
1.06k stars 202 forks source link

AttributeError: 'DataLoader' object has no attribute '_dataset_kind' #63

Open lpkoh opened 4 years ago

lpkoh commented 4 years ago

Hi,

I am currently on Windows, Python 3.7. I have installed pip install torch==1.3.0+cpu torchvision==0.4.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

When I run: python run_classifier.py --load downloads/transformer_sst.clf --data data/binary_sst/test.csv --model "transformer" I get AttributeError: 'DataLoader' object has no attribute '_dataset_kind'. I have switch through many versions, like torch 1.2.0 and torchvision==0.4.0, but the issue persists. May I know if anyone has worked around this?

martian07 commented 4 years ago

same error, even tried earlier commits still didn't ran

martian07 commented 4 years ago

resolved with !pip install torch==1.0.1 torchvision==0.2.2

forest1988 commented 4 years ago

I encountered a similar problem.

It seems that the defined 'DataLoader' in this repository corresponds to the old 'DataLoader' and does not support the newer version.

https://github.com/NVIDIA/sentiment-discovery/blob/master/data_utils/loaders.py#L91 I added 2 lines in def __init__() of class DataLoader(data.DataLoader) as below.

class DataLoader(data.DataLoader):
    """normal data loader except with options for distributed data batch sampling + wrap around"""
    def __init__(self, dataset, batch_size=1, shuffle=False, sampler=None, batch_sampler=None,
                 num_workers=0, collate_fn=default_collate, pin_memory=False, drop_last=False,
                 transpose=False, world_size=2, rank=-1, distributed=False, wrap_last=False,
                 timeout=0, worker_init_fn=None):
        self.dataset = dataset

        # added 2019-11-24
        self._dataset_kind = None
        self.multiprocessing_context = None

        self.batch_size = batch_size

I haven't confirmed that it works correctly, but at least it works without error.

forest1988 commented 4 years ago

Unfortunately, the method I wrote above may not be performing properly. I tried using "Finetuned Plutchik Transformer" by the way above, but it doesn't seem to get good results...

self._dataset_kind = None

may be undesirable.

matthias-tschoepe commented 4 years ago

I had a similar problem maybe it helps someone: I tried to load my own Dataloader object, which I saved with a previous version of Pytorch. After updating Pytorch my Dataloader object could be loaded, but I couldn't iterate over it. So, I had to create a new Dataloader object with the new Pytorch version.

ArronChan commented 4 years ago

I had a similar problem maybe it helps someone: I tried to load my own Dataloader object, which I saved with a previous version of Pytorch. After updating Pytorch my Dataloader object could be loaded, but I couldn't iterate over it. So, I had to create a new Dataloader object with the new Pytorch version.

how to create a new Dataloader object with the new Pytorch version? I am so confused

mgayari commented 4 years ago

AttributeError: 'DirectoryDataLoader' object has no attribute 'label_map'. Please help.