How to used custom dataset in Conv-TasNet

userTsai: <p>I created a music dataset including vocal and instrument, and I tried to use Conv-tasnet to sepatate the vocal and instrument. I have successfully used other people’s datasets for training first, but when I use my dataset to train, it keeps failing and I can’t find the problem. Here is the error and my datasets. Did I miss something?<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/0/106faf9f11f0c81d87ddfd4c3025abd9755e4deb.png" data-download-href="https://discuss.pytorch.org/uploads/default/106faf9f11f0c81d87ddfd4c3025abd9755e4deb" title="2021-10-21 16-50-20 的螢幕擷圖"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/0/106faf9f11f0c81d87ddfd4c3025abd9755e4deb_2_690x388.png" alt="2021-10-21 16-50-20 的螢幕擷圖" data-base62-sha1="2loVotPViEqRZyQwdvVNkcrgT3B" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/0/106faf9f11f0c81d87ddfd4c3025abd9755e4deb_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/0/106faf9f11f0c81d87ddfd4c3025abd9755e4deb_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/1/0/106faf9f11f0c81d87ddfd4c3025abd9755e4deb_2_1380x776.png 2x" data-dominant-color="E7E5E6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">2021-10-21 16-50-20 的螢幕擷圖</span><span class="informations">1920×1080 237 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/8/38557e8ece92d29827f1202ba3b89dca059fd899.png" data-download-href="https://discuss.pytorch.org/uploads/default/38557e8ece92d29827f1202ba3b89dca059fd899" title="2021-10-21 16-51-29 的螢幕擷圖"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/8/38557e8ece92d29827f1202ba3b89dca059fd899_2_690x388.png" alt="2021-10-21 16-51-29 的螢幕擷圖" data-base62-sha1="82lUmTdVI9gbMsblnbnMwlAGXTb" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/8/38557e8ece92d29827f1202ba3b89dca059fd899_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/8/38557e8ece92d29827f1202ba3b89dca059fd899_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/3/8/38557e8ece92d29827f1202ba3b89dca059fd899_2_1380x776.png 2x" data-dominant-color="EEEDEE"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">2021-10-21 16-51-29 的螢幕擷圖</span><span class="informations">1920×1080 101 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/f/ff132511322e09552ba88118681b8d450338036f.png" data-download-href="https://discuss.pytorch.org/uploads/default/ff132511322e09552ba88118681b8d450338036f" title="2021-10-21 16-51-33 的螢幕擷圖"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/f/f/ff132511322e09552ba88118681b8d450338036f_2_690x388.png" alt="2021-10-21 16-51-33 的螢幕擷圖" data-base62-sha1="AouLTtmct2Flg3By466Scs96aib" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/f/f/ff132511322e09552ba88118681b8d450338036f_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/f/f/ff132511322e09552ba88118681b8d450338036f_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/f/f/ff132511322e09552ba88118681b8d450338036f_2_1380x776.png 2x" data-dominant-color="EEEDEE"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">2021-10-21 16-51-33 的螢幕擷圖</span><span class="informations">1920×1080 102 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/4/a4a9ee738c7dbf7b34eff5f1875c9f0a05900efe.png" data-download-href="https://discuss.pytorch.org/uploads/default/a4a9ee738c7dbf7b34eff5f1875c9f0a05900efe" title="2021-10-21 16-59-34 的螢幕擷圖"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a4a9ee738c7dbf7b34eff5f1875c9f0a05900efe_2_690x388.png" alt="2021-10-21 16-59-34 的螢幕擷圖" data-base62-sha1="nuGnETL2iynCeqq8nQN7fwC4kd8" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a4a9ee738c7dbf7b34eff5f1875c9f0a05900efe_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a4a9ee738c7dbf7b34eff5f1875c9f0a05900efe_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a4a9ee738c7dbf7b34eff5f1875c9f0a05900efe_2_1380x776.png 2x" data-dominant-color="EAE9E9"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">2021-10-21 16-59-34 的螢幕擷圖</span><span class="informations">1920×1080 294 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>The code in your screenshots is quite hard to read, so please post code snippets by wrapping them into three backticks ```, as it’s easier to read/debug, and the search engine would be able to index it as well if other users hit similar issues.</p>
<p>Based on what I can see it seems that a local variable is references before its assignment, so you would need to check where its definition is.</p>

userTsai: <p>Thank you for your reply. I am sorry that I forgot to give the complete code.</p>
<p>“i” is the index of “data”,and there is no other same variable outside the def.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/7/c753352f271691c186515bdbee091e35ddf5d4c6.png" data-download-href="https://discuss.pytorch.org/uploads/default/c753352f271691c186515bdbee091e35ddf5d4c6" title="2021-10-21 17-41-51 的螢幕擷圖"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/7/c753352f271691c186515bdbee091e35ddf5d4c6_2_690x388.png" alt="2021-10-21 17-41-51 的螢幕擷圖" data-base62-sha1="srjhSCxOm3fsdyitgY0qX63llEW" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/7/c753352f271691c186515bdbee091e35ddf5d4c6_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/c/7/c753352f271691c186515bdbee091e35ddf5d4c6_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/c/7/c753352f271691c186515bdbee091e35ddf5d4c6_2_1380x776.png 2x" data-dominant-color="ECEAEB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">2021-10-21 17-41-51 的螢幕擷圖</span><span class="informations">1920×1080 276 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>If the <code>data_loader</code> is empty, <code>i</code> will be undefined:</p>
<pre><code class="lang-python">def fun():
    for i in range(0):
        print('inside loop')
    return 1 / i

fun()
&gt; UnboundLocalError: local variable 'i' referenced before assignment
</code></pre>
<p>PS: I would still recommend to post code snippets directly instead of screenshots.</p>

nateanl: <p>Hi <a class="mention" href="/u/usertsai">@userTsai</a>, there is a training recipe of Conv-TasNet in torchaudio. You can follow the implementation here: <a href="https://github.com/pytorch/audio/blob/main/examples/source_separation/lightning_train.py#L280" class="inline-onebox" rel="noopener nofollow ugc">audio/lightning_train.py at main · pytorch/audio · GitHub</a> for your own dataset.</p>