torch_ecg icon indicating copy to clipboard operation
torch_ecg copied to clipboard

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

Open ZhaoXiangyu99 opened this issue 2 years ago • 1 comments

我在使用官方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) 请问应该怎么调整输入呢

ZhaoXiangyu99 avatar Apr 10 '23 07:04 ZhaoXiangyu99

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.

wenh06 avatar Apr 10 '23 10:04 wenh06