Report NaN

This commit is contained in:
James Betker 2022-02-22 23:09:37 -07:00
parent 7201b4500c
commit 03752c1cd6
2 changed files with 2 additions and 1 deletions

View File

@ -140,7 +140,7 @@ class TextWavLoader(torch.utils.data.Dataset):
tseq, wav, text, path = self.get_wav_text_pair(self.audiopaths_and_text[index])
if text is None or len(text.strip()) == 0:
raise ValueError
if wav is None or wav.shape[-1] < (.1 * self.sample_rate):
if wav is None or wav.shape[-1] < (.6 * self.sample_rate):
# Ultra short clips are also useless (and can cause problems within some models).
raise ValueError
cond, cond_is_self = load_similar_clips(self.audiopaths_and_text[index][0], self.conditioning_length, self.sample_rate,

View File

@ -332,6 +332,7 @@ class ConfigurableStep(Module):
for pgn, pg in zip(opt._group_names, opt.param_groups):
grad_norm = clip_grad_norm(pg['params'], pgn, self.clip_grad_eps)
if torch.isnan(grad_norm):
print("NaN found in clip_grad; zeroing grad and trying again.")
nan_found = True
self.nan_counter += 1