如何对读入的(1000, 250, 250, 3)的数组归一化(1000是图片总数)
时间: 2024-03-06 11:49:36 浏览: 31
可以使用以下代码将读入的数组归一化:
```python
import numpy as np
# 假设读入的数组为data
data = np.array([...]) # 读入的数组
# 归一化
data = data.astype('float32') / 255.0
```
其中,`astype('float32')`将数组的数据类型转换为`float32`,`/ 255.0`将数组中的每个元素除以255,实现归一化。最后得到的`data`数组的值范围在0到1之间。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![c](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)