carlomarxdk / life2vec-light

Basic implementation of the life2vec model with the dummy data.
https://life2vec.dk
MIT License
39 stars 11 forks source link

ValueError: Caught ValueError in DataLoader worker process 0. #3

Closed SlmpIex closed 3 months ago

SlmpIex commented 6 months ago

Hi there! Nice codebase..helps a lot with my current work.

I just started reviewing your code and noticed a ValueError when running your simple_workflow.ipynb file. The exception occurs during epoch 8 of training. Since there already was an issue regarding the execution of trainer.fit(model=l2v, datamodule=datamodule) I figured posting an issue here as well.

If I can assist in any way or providing additional information, please let me know.

ValueError: Caught ValueError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/testuser/project/venv_wsl/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop data = fetcher.fetch(index) File "/home/testuser/project/venv_wsl/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/testuser/project/venv_wsl/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/testuser/project/venv_wsl/lib/python3.10/site-packages/torch/utils/data/dataset.py", line 335, in getitem return self.datasets[dataset_idx][sample_idx] File "/home/testuser/project/example_code/03_life2vec/src/dataloaders/dataset.py", line 93, in getitem content = self._transform(content) File "/home/testuser/project/example_code/03_life2vec/src/dataloaders/dataset.py", line 52, in _transform return self.transform(x) File "/home/testuser/project/example_code/03_life2vec/src/dataloaders/tasks/base.py", line 94, in preprocessor x = self.augment_document(x, is_train=is_train) File "/home/testuser/project/example_code/03_life2vec/src/dataloaders/tasks/base.py", line 124, in augment_document document = resample_document(document) File "/home/testuser/project/example_code/03_life2vec/src/dataloaders/augment.py", line 76, in resample_document num_to_remove = np.random.randint( File "numpy/random/mtrand.pyx", line 782, in numpy.random.mtrand.RandomState.randint File "numpy/random/_bounded_integers.pyx", line 1334, in numpy.random._bounded_integers._rand_int64 ValueError: high <= 0

quantumdotsss commented 4 months ago

I got the same issue!

quantumdotsss commented 4 months ago

I have fix it. for life2vec-light_old/src/dataloaders/tasks/base.py line 117: change the p = np.random.uniform(low=0.0, high=1.0, size=[5]) to p = np.random.uniform(low=0.1, high=1.0, size=[5])

        if is_train:
            # print(f'self.p_sequence_resample is : {self.p_sequence_resample}')

            # AUGMENTATION WITH NOISE
            p = np.random.uniform(low=0.1, high=1.0, size=[5])

            # Should be in the exact order
            # 1. TIMECUT (returns cut document)
            if p[0] < self.p_sequence_timecut:
                document = make_timecut(document)  # random timecut
            # 2. RESAMPLE DOCUMENT
            print(f'p[1] is : {p[1]}')
            if p[1] < self.p_sequence_resample:
bruceyyu commented 4 months ago

I got the same issue, and I suspect this behavior is caused by this weird assignment below, which makes every person's sentences empty. After removing this line the code works fine. I would appreciate if the authors could add some explanation to it @carlomarxdk

https://github.com/carlomarxdk/life2vec-light/blob/dec1d9ec389a24ced67ca72db996b925db5e847f/src/dataloaders/tasks/base.py#L188

carlomarxdk commented 4 months ago

I got the same issue, and I suspect this behavior is caused by this weird assignment below, which makes every person's sentences empty. After removing this line, the code works fine. I would appreciate if the authors could add some explanation to it @carlomarxdk

https://github.com/carlomarxdk/life2vec-light/blob/dec1d9ec389a24ced67ca72db996b925db5e847f/src/dataloaders/tasks/base.py#L188

@bruceyyu Thanks for noticing the issue. I have included this line to disable the sequence augmentation. In principle, timecut_pos tells us at what timestep we cut the sequence before feeding it to the model (on the training). I will remove this line in the next commit.

carlomarxdk commented 4 months ago

I have fix it. for life2vec-light_old/src/dataloaders/tasks/base.py line 117: change the p = np.random.uniform(low=0.0, high=1.0, size=[5]) to p = np.random.uniform(low=0.1, high=1.0, size=[5])

        if is_train:
            # print(f'self.p_sequence_resample is : {self.p_sequence_resample}')

            # AUGMENTATION WITH NOISE
            p = np.random.uniform(low=0.1, high=1.0, size=[5])

            # Should be in the exact order
            # 1. TIMECUT (returns cut document)
            if p[0] < self.p_sequence_timecut:
                document = make_timecut(document)  # random timecut
            # 2. RESAMPLE DOCUMENT
            print(f'p[1] is : {p[1]}')
            if p[1] < self.p_sequence_resample:

@quantumdotsss I would not suggest switching the low to 0.1 (it might disable some of the augmentations). For example, if your p_sequence_timecut=0.05, then it would never be activated, since the p[0] is going to be always higher than 0.05

carlomarxdk commented 3 months ago

Let me know if the v0.2.0 does not solve the issue (see overview)