mat1 and mat2 must have the same dtype等三个报错

报错

Traceback (most recent call last):
  File "/home/cszx/c1/zgp/3D-ADS-main/main.py", line 68, in <module>
    run_3d_ads()
  File "/home/cszx/c1/zgp/3D-ADS-main/main.py", line 27, in run_3d_ads
    image_rocaucs, pixel_rocaucs, au_pros = patchcore.evaluate(cls)
  File "/home/cszx/c1/zgp/3D-ADS-main/patchcore_runner.py", line 46, in evaluate
    method.predict(sample, mask, label)
  File "/home/cszx/c1/zgp/3D-ADS-main/feature_extractors/rgb_fpfh_sim_features.py", line 44, in predict
    concat_patch = self.network(concat_patch)
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/cszx/c1/zgp/3D-ADS-main/feature_extractors/features.py", line 24, in forward
    x = self.fc1(x)
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
RuntimeError: mat1 and mat2 must have the same dtype

concat_patch = concat_patch.float() # 确保输入数据是float32类型
output = self.network(concat_patch)

报错

RuntimeError: mat1 and mat2 shapes cannot be multiplied (784x1569 and 784x128)

.T转置

报错

  File "/home/cszx/c1/zgp/3D-ADS-main/main.py", line 26, in run_3d_ads
    patchcore.fit(cls)
  File "/home/cszx/c1/zgp/3D-ADS-main/patchcore_runner.py", line 36, in fit
    method.run_coreset()
  File "/home/cszx/c1/zgp/3D-ADS-main/feature_extractors/features.py", line 117, in run_coreset
    eps=self.coreset_eps, )
  File "/home/cszx/c1/zgp/3D-ADS-main/feature_extractors/features.py", line 137, in get_coreset_idx_randomp
    z_lib = torch.tensor(transformer.fit_transform(z_lib))
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/sklearn/base.py", line 852, in fit_transform
    return self.fit(X, **fit_params).transform(X)
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/sklearn/random_projection.py", line 347, in fit
    X = self._validate_data(X, accept_sparse=["csr", "csc"])
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/sklearn/base.py", line 566, in _validate_data
    X = check_array(X, **check_params)
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/sklearn/utils/validation.py", line 746, in check_array
    array = np.asarray(array, order=order, dtype=dtype)
  File "/home/cszx/miniconda3/envs/zgp_3dads/lib/python3.7/site-packages/torch/_tensor.py", line 956, in __array__
    return self.numpy()
RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.

z_lib = torch.tensor(transformer.fit_transform(z_lib.detach()))
可以了
running coreset for RGB + FPFH+simplenet on class bagel…
Fitting random projections. Start dim = torch.Size([382836, 784]).
DONE. Transformed dim = torch.Size([382836, 317]).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值