YuxiangZhang-BIT / IEEE_TIP_SDEnet

Single-source Domain Expansion Network for Cross-Scene Hyperspectral Image Classification, IEEE TIP, 2023.
MIT License
34 stars 8 forks source link

TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of: #1

Open luminous33 opened 1 year ago

luminous33 commented 1 year ago

I'm encountering a TypeError in our project and would like to inquire about it. The error message is as follows:

TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:

The error occurs on line 23 of /data/test/IEEE_TIP_SDEnet/network/discriminator.py. It seems that the nn.Linear() function is causing the error due to receiving incorrect arguments when calling torch.empty().

We would appreciate any help or advice you could offer regarding this issue. Thank you very much:)

luminous33 commented 1 year ago

Traceback (most recent call last): File "/data/test/IEEE_TIP_SDEnet/train.py", line 257, in experiment() File "/data/test/IEEE_TIP_SDEnet/train.py", line 166, in experiment D_net = discriminator.Discriminator(inchannel=N_BANDS, outchannel=args.pro_dim, num_classes=num_classes, File "/data/test/IEEE_TIP_SDEnet/network/discriminator.py", line 23, in init self.cls_head_src = nn.Linear(dim, num_classes) File "/usr/local/anaconda3/envs/hyper_image/lib/python3.9/site-packages/torch/nn/modules/linear.py", line 86, in init self.weight = Parameter(torch.empty((out_features, in_features), **factory_kwargs)) TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:

fanleyuan commented 7 months ago

修改discriminator.py中第23行为self.cls_head_src = nn.Linear(dim, int(num_classes))