question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeError: Expected object of scalar type Float but got scalar type Int for argument #2 'target' When training forward network

See original GitHub issue

Hi

I am using Windows 10, Pytorch 1.2, python 3.7 and all other required libs. I was able to generate the preprocessor data and fully train the tacotron model and generate the GTAs. But now I come to train the forward network and it looks like the dur parameter in for i, (x, m, ids, lens, dur) in enumerate(session.train_set, 1): is an int tensor and it expects a float tensor.

  File "train_forward.py", line 98, in <module>
    trainer.train(model, optimizer)
  File "D:\speech\ForwardTacotron-master\ForwardTacotron-master\trainer\forward_trainer.py", line 37, in train
    self.train_session(model, optimizer, session)
  File "D:\speech\ForwardTacotron-master\ForwardTacotron-master\trainer\forward_trainer.py", line 67, in train_session
    dur_loss = F.l1_loss(dur_hat, dur)
  File "C:\Users\Josh\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\functional.py", line 2165, in l1_loss
    ret = torch._C._nn.l1_loss(expanded_input, expanded_target, _Reduction.get_enum(reduction))
RuntimeError: Expected object of scalar type Float but got scalar type Int for argument #2 'target'

dur tensor looks like:

tensor([[ 0,  6, 14,  ...,  0,  0,  0],
        [ 0,  8,  9,  ...,  0,  0,  0],
        [ 0,  5,  8,  ...,  0,  0,  0],
        ...,
        [ 8,  9, 16,  ...,  0,  0,  0],
        [ 0,  8,  8,  ...,  0,  0,  0],
        [ 0,  6, 12,  ...,  0,  0,  0]], dtype=torch.int32)

Would you have any ideas what could cause this and how to address it?

Thank you

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
cschaefer26commented, Jun 30, 2020

Sorry to hear that, 1.5steps/s is not bad, although it should be around 3 for batch size 32.

0reactions
jmasterxcommented, Jun 29, 2020

Upgrading pytorch to 1.5.1 and getting latest nvidia drivers produced the same result. Does not seem to happen on 2080xx cards,just lower tier like mine. No big deal though, 1.5 steps/sec is much better than 0.26 without cudnn at all!

Read more comments on GitHub >

github_iconTop Results From Across the Web

RuntimeError: Expected object of scalar type Long but got ...
I'm not sure why the program expects a long object because all my Tensors are in float form. I looked at threads with...
Read more >
RuntimeError: Expected object of scalar ... - PyTorch Forums
I have a NN that ends with the following linear layers dense = nn.Linear(input_size, 1) if I use CrossEntropyLoss as loss function (as...
Read more >
RuntimeError: Expected object of scalar type Long ... - GitHub
During data loading, the target should be of type Long for cross-entropy loss. In the dataloader set: target = target.to(dtype=torch.long) Whereas, in case...
Read more >
pytorch RuntimeError: Expected object of scalar type Double ...
I am trying to implement a custom dataset for my neural network. But got this error when running the forward function. The code...
Read more >
runtimeerror: expected scalar type long but found float - You.com
When the error is RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #4 'mat1', you would need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found