_nd_image.uniform_filter1d(input, size, axis, output, mode, cval, RuntimeError: array type dtype('float16') not supported
时间: 2024-04-29 10:21:20 浏览: 20
This error message suggests that the input array has a data type of 'float16', which is not supported by the 'uniform_filter1d' function in the 'nd_image' module.
To resolve this issue, you can try converting the input array to a supported data type (e.g. 'float32' or 'float64') using the 'astype' method before passing it to the 'uniform_filter1d' function:
``` python
import numpy as np
from scipy import ndimage
input = np.random.rand(100).astype(np.float16)
size = 3
axis = 0
# convert input array to float32
input = input.astype(np.float32)
# apply uniform filter
output = ndimage.uniform_filter1d(input, size=size, axis=axis)
print(output)
```
Alternatively, you can use a different function that supports 'float16' data type, such as 'gaussian_filter1d' or 'median_filter1d', depending on your specific use case.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)