libffcv / ffcv-imagenet

Train ImageNet *fast* in 500 lines of code with FFCV
Apache License 2.0
136 stars 34 forks source link

batch_size=1 causes error when Squeeze() is in the "label" pipeline #13

Open botcs opened 2 years ago

botcs commented 2 years ago
Exception in thread Thread-6:
Traceback (most recent call last):
  File "/home/cbotos/miniconda3/envs/ffcv/lib/python3.9/threading.py", line 980, in _bootstrap_inner
    self.run()
  File "/home/cbotos/miniconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/loader/epoch_iterator.py", line 79, in run
    result = self.run_pipeline(b_ix, ixes, slot, events[slot])
  File "/home/cbotos/miniconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/loader/epoch_iterator.py", line 138, in run_pipeline
    return tuple(x[:len(batch_indices)] for x in args)
  File "/home/cbotos/miniconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/loader/epoch_iterator.py", line 138, in <genexpr>
    return tuple(x[:len(batch_indices)] for x in args)
IndexError: slice() cannot be applied to a 0-dim tensor.

I would say that this error is sorta unexpected, but I could have anticipated it since the Squeeze is also squishing the batch dimension in this case (if I understood the situation correctly)

andrewilyas commented 2 years ago

Hi @botcs ! This should be fixed by #14 --- try using that branch and seeing if it fixes your issue? If it does we'll merge it in soon.