How to iterate over VCTK dataset elements?

YK11: <p>Hello!<br>
I am trying to go through VCTK dataset in this way:</p>
<pre><code class="lang-auto">train_set = datasets.VCTK(root = 'processed/training.pt', download = True, transform = transforms.PadTrim(max_len=30000))
training_data_loader = DataLoader(dataset = train_set,
            num_workers=opt.nThreads, batch_size=opt.batchSize,shuffle=True)

for batch_idx, batch in enumerate(training_data_loader):
    print(batch_idx)
    ........

</code></pre>
<p>However, it prints only 0 and shows the following error:</p>
<pre><code class="lang-auto">0
Traceback (most recent call last):
  File "main_audio.py", line 153, in &lt;module&gt;
    for batch_idx, batch in enumerate(training_data_loader):
  File "/mnt/home/20140941/.conda/envs/opt_anaconda/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 281, in __next__
    return self._process_next_batch(batch)
  File "/mnt/home/20140941/.conda/envs/opt_anaconda/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 301, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
IndexError: Traceback (most recent call last):
  File "/mnt/home/20140941/.conda/envs/opt_anaconda/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 55, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "build/bdist.linux-x86_64/egg/torchaudio/datasets/vctk.py", line 126, in __getitem__
    audio, target = self.data[index], self.labels[index]
IndexError: tuple index out of range

</code></pre>
<p>How can I solve this problem?</p>

dhpollack: <p>I assume you are using the torchaudio library.  The root should be a folder not a file.  Otherwise, you’ll have to make a custom <code>torch.utils.data.Dataset</code>.  Also, did you check to see that it actually downloads the files?  The VCTK dataset is very large and takes a long time to download.  You should probably just run the first line in a REPL and see if the dataset gets downloaded correctly.</p>

YK11: <p>Thanks for your reply! I fixed root and all data was downloaded. However, there is still problem.</p>
<pre><code class="lang-auto">train_set = datasets.VCTK(root = '.', download = True, transform = transforms.PadTrim(max_len=30000))
training_data_loader = DataLoader(dataset = train_set,
            num_workers=opt.nThreads, batch_size=2,shuffle=True)

for batch_idx, batch in enumerate(training_data_loader, 0):
    print(batch_idx)
</code></pre>
<p>The length of training set is 44257. When I run code it prints integers from 1 to 20 (supposed to print to 22129). And shows similar errror.</p>
<pre><code class="lang-auto">    for batch_idx, batch in enumerate(training_data_loader, 0):
  File "/mnt/home/20140941/.conda/envs/opt_anaconda/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 281, in __next__
    return self._process_next_batch(batch)
  File "/mnt/home/20140941/.conda/envs/opt_anaconda/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 301, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
IndexError: Traceback (most recent call last):
  File "/mnt/home/20140941/.conda/envs/opt_anaconda/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 55, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "build/bdist.linux-x86_64/egg/torchaudio/datasets/vctk.py", line 126, in __getitem__
    audio, target = self.data[index], self.labels[index]
IndexError: tuple index out of range

</code></pre>
<p>Please, help!</p>

tks: <p>Did you ever get an answer for this? I’m running into the exact same issue now…</p>
<p>It seems to work as expected when I just iterate through the dataset directly though (rather than using the loader).</p>