Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single word input leads to ValueError: Expected more than 1 spatial element when training, got input size torch.Size([1, 512, 1]) #149

Open
Graf-D opened this issue Mar 28, 2022 · 1 comment

Comments

@Graf-D
Copy link

Graf-D commented Mar 28, 2022

Hello!

I've got the following exception: ValueError: Expected more than 1 spatial element when training, got input size torch.Size([1, 512, 1]) on the model forward pass (z, log_s_list, gate_pred, attn, attn_logprob, mean, log_var, prob = model(mel, spk_ids, txt, in_lens, out_lens, attn_prior))

I've discovered that this exception occurs if the whole text (txt) is a single word (e.g. "what"). I found some mentions of this problem in this repo's issues but no solution was provided.

The full traceback:

  File "/slot/sandbox/nv_tmpfs/d/in/script/0_script_unpacked/s2t_probs/flowtron_score_text.py", line 147, in <module>
    attn_logprob, mean, log_var, prob) = model(
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/slot/sandbox/nv_tmpfs/d/in/script/0_script_unpacked/s2t_probs/flowtron/flowtron.py", line 818, in forward
    text = self.encoder(text, in_lens)
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/slot/sandbox/nv_tmpfs/d/in/script/0_script_unpacked/s2t_probs/flowtron/flowtron.py", line 436, in forward
    F.relu(conv(curr_x)),
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
    input = module(input)
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/modules/instancenorm.py", line 57, in forward
    return F.instance_norm(
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/functional.py", line 2326, in instance_norm
    _verify_spatial_size(input.size())
  File "/anaconda3/lib/python3.8/site-packages/torch/nn/functional.py", line 2293, in _verify_spatial_size
    raise ValueError("Expected more than 1 spatial element when training, got input size {}".format(size))
ValueError: Expected more than 1 spatial element when training, got input size torch.Size([1, 512, 1])

I understand why processing a sequence of a length 1 through an instance norm causes an exception. However, is there a way to make it work? I mean, maybe I could add some special token to the string or something like that.

@lunalulu
Copy link

lunalulu commented May 5, 2023

any progress?
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants