Giter Site home page Giter Site logo

Comments (4)

VSainteuf avatar VSainteuf commented on July 23, 2024

HI @manapshymyr-OB ,
can you have a look at this issue and see if it helps you?

from pytorch-psetae.

manapshymyr-OB avatar manapshymyr-OB commented on July 23, 2024

I executed following your comments and getting this error:

Traceback (most recent call last):
  File "/agrospace/lightweight-temporal-attention-pytorch/train.py", line 363, in <module>
    main(config)
  File "/agrospace/lightweight-temporal-attention-pytorch/train.py", line 256, in main
    train_metrics = train_epoch(model, optimizer, criterion, train_loader, device=device, config=config)
  File "/agrospace/lightweight-temporal-attention-pytorch/train.py", line 26, in train_epoch
    for i, (x, y) in enumerate(data_loader):
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 632, in __next__
    data = self._next_data()
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1350, in _next_data
    return self._process_data(data)
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1376, in _process_data
    data.reraise()
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/_utils.py", line 694, in reraise
    raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 55, in fetch
    return self.collate_fn(data)
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/collate.py", line 280, in default_collate
    return collate(batch, collate_fn_map=default_collate_fn_map)
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/collate.py", line 143, in collate
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/collate.py", line 143, in <listcomp>
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/collate.py", line 143, in collate
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/collate.py", line 143, in <listcomp>
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/collate.py", line 120, in collate
    return collate_fn_map[elem_type](batch, collate_fn_map=collate_fn_map)
  File "/agrospace/lightweight-temporal-attention-pytorch/vevn/lib/python3.10/site-packages/torch/utils/data/_utils/collate.py", line 177, in collate_tensor_fn
    return torch.stack(batch, 0, out=out)
RuntimeError: stack expects each tensor to be equal size, but got [123, 8, 64] at entry 0 and [117, 8, 64] at entry 1

and when I print the batch shapes with the following code:

for b in batch:
        print(b.shape)
    return torch.stack(batch, 0, out=out)

I see this:
image
which is correct (the first number represents sequence)
Any ideas how to work correctly with the sequential data (so I do not have equal data in terms of the time)?

from pytorch-psetae.

VSainteuf avatar VSainteuf commented on July 23, 2024

yes if you have time series of varying length, you need to implement a "collate" function with a padding strategy to form batches of equal size.
You can have a look at how we did it for the PASTIS dataset here

from pytorch-psetae.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.