79837837

Date: 2025-12-04 11:04:47
Score: 5.5
Natty: 6
Report link

What if the tensor has no elements in it?

How do i solve this?

import torch
x = torch.tensor([])
x = torch.cat((x,3),0)
#outputs an error
Exception has occurred: TypeError 
expected Tensor as element 1 in argument 0, but got int
x = torch.cat((x,3),0)
        ^^^^^^^^^^^^^^^^^^
TypeError: expected Tensor as element 1 in argument 0, but got int
Reasons:
  • Blacklisted phrase (1): How do i
  • RegEx Blacklisted phrase (1.5): solve this?
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): What if the
  • Low reputation (1):
Posted by: Max xander