-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
good first issuemodule: edge casesAdversarial inputs unlikely to occur in practiceAdversarial inputs unlikely to occur in practicemodule: error checkingBugs related to incorrect/lacking error checkingBugs related to incorrect/lacking error checkingmodule: nnRelated to torch.nnRelated to torch.nnmodule: python frontendFor issues relating to PyTorch's Python frontendFor issues relating to PyTorch's Python frontendtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Describe the bug
Setting a wrong type value instead of a correct float type value to in_features and out_features argument of nn.Linear() gets the indirect error messages as shown below:
import torch
from torch import nn
my_tensor = torch.tensor([2., 7., 4.])
# ↓↓
linear = nn.Linear(in_features=3., out_features=5)TypeError: empty(): argument 'size' failed to unpack the object at pos 2 with error "type must be tuple of ints,but got float"
import torch
from torch import nn
my_tensor = torch.tensor([2., 7., 4.])
# ↓↓↓↓↓↓
linear = nn.Linear(in_features=3, out_features=5.+0.j)TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:
* (tuple of ints size, *, tuple of names names, torch.memory_format memory_format = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
* (tuple of ints size, *, torch.memory_format memory_format = None, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
So, the error messages should be something like as shown below:
in_featuresmust befloat.
out_featuresmust befloat.
Versions
import torch
torch.__version__ # 2.4.0+cu121cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki @malfet
Metadata
Metadata
Assignees
Labels
good first issuemodule: edge casesAdversarial inputs unlikely to occur in practiceAdversarial inputs unlikely to occur in practicemodule: error checkingBugs related to incorrect/lacking error checkingBugs related to incorrect/lacking error checkingmodule: nnRelated to torch.nnRelated to torch.nnmodule: python frontendFor issues relating to PyTorch's Python frontendFor issues relating to PyTorch's Python frontendtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module