CIA-Oceanix / TrAISformer

Pytorch implementation of TrAISformer---A generative transformer for AIS trajectory prediction (https://arxiv.org/abs/2109.03958).
Other
108 stars 37 forks source link

AttributeError: '_SingleProcessDataLoaderIter' object has no attribute 'next' #32

Open zsxxxx98 opened 4 months ago

zsxxxx98 commented 4 months ago

http://t.csdnimg.cn/8WwlT

solutions: x = next(data) or x = data.next()

mct-lrh commented 2 months ago

Same issue.

$ python trAISformer.py
======= Directory to store trained models: ./results/ct_dma-pos-pos_vicinity-10-40-blur-True-False-2-1.0-data_size-250-270-30-72-embd_size-256-256-128-128-head-8-8-bs-32-lr-0.0006-seqlen-18-120/
Loading ./data/ct_dma/ct_dma_train.pkl...
10605 9144
Length: 9144
Creating pytorch dataset...
Loading ./data/ct_dma/ct_dma_valid.pkl...
1481 1291
Length: 1291
Creating pytorch dataset...
Loading ./data/ct_dma/ct_dma_test.pkl...
1593 1453
Length: 1453
Creating pytorch dataset...
2024-08-30 15:26:22,227 - models - number of parameters: 5.742055e+07
epoch 1 iter 285: loss 4.91164. lr 5.993205e-04: 100%|█| 286/286 [02:45<00:00,  1.73it/s]
2024-08-30 15:29:21,020 - root - Training, epoch 1, loss 9.51605, lr 5.993205e-04.
2024-08-30 15:29:49,405 - root - Valid, epoch 1, loss 4.60139.
2024-08-30 15:29:49,408 - root - Best epoch: 001, saving model to ./results/ct_dma-pos-pos_vicinity-10-40-blur-True-False-2-1.0-data_size-250-270-30-72-embd_size-256-256-128-128-head-8-8-bs-32-lr-0.0006-seqlen-18-120/model.pt
Traceback (most recent call last):
  File "C:\Users\laura\GitHub\TrAISformer\trAISformer.py", line 121, in <module>
    trainer.train()
  File "C:\Users\laura\GitHub\TrAISformer\trainers.py", line 282, in train
    seqs, masks, seqlens, mmsis, time_starts = iter(aisdls["test"]).next()
AttributeError: '_SingleProcessDataLoaderIter' object has no attribute 'next'

Windows 11 anaconda3 pytorch 2.4.0 pytorch-cuda 12.1

@zsxxxx98 's second solution did not work, but the first one did. Change seqs, masks, seqlens, mmsis, time_starts = iter(aisdls["test"]).next() to seqs, masks, seqlens, mmsis, time_starts = next(iter(aisdls["test"]))