DeepPSP / torch_ecg

Deep learning ECG models implemented using PyTorch
MIT License
161 stars 20 forks source link

UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. #8

Open ZhaoXiangyu99 opened 1 year ago

ZhaoXiangyu99 commented 1 year ago

我在使用官方demo的时候,控制台有个warnng: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at ../torch/csrc/utils/tensor_new.cpp:230.) ampl = torch.as_tensor(ampl, dtype=sig.dtype, device=sig.device).unsqueeze(-1) 请问应该怎么调整输入呢

wenh06 commented 1 year ago

The reason for this warning seems to be that you are not using the latest version, since the code

ampl = torch.as_tensor(ampl, dtype=sig.dtype, device=sig.device).unsqueeze(-1)

where this warning is raised has been modified to

ampl = torch.as_tensor(
    np.array(ampl), dtype=sig.dtype, device=sig.device
).unsqueeze(-1)

Please check here.

If you have any other problems, please feel free to open issues.