如何将4维 NumPy 数组转换为一维数组
可以使用 NumPy 的 flatten() 函数将 4 维数组转换为一维数组。
import numpy as np
arr = np.array([4])
arr_1d = arr.flatten()
print(arr_1d)
输出结果:
[4]
原文地址: https://www.cveoy.top/t/topic/mRAt 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
可以使用 NumPy 的 flatten() 函数将 4 维数组转换为一维数组。
import numpy as np
arr = np.array([4])
arr_1d = arr.flatten()
print(arr_1d)
输出结果:
[4]
原文地址: https://www.cveoy.top/t/topic/mRAt 著作权归作者所有。请勿转载和采集!