时间:2021-07-01 10:21:17 帮助过:364人阅读
numpy.expand_dims(a, axis)
Examples
- >>> x = np.array([1,2])
- >>> x.shape
- (2,)
- >>> y = np.expand_dims(x, axis=0)
- >>> y
- array([[1, 2]])
- >>> y.shape
- (1, 2)
- >>> y = np.expand_dims(x, axis=1) # Equivalent to x[:,newaxis]
- >>> y
- array([[1],
- [2]])
- >>> y.shape
- (2, 1)
相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!
推荐阅读:
python操作excel读写数据
Python Unittest怎么进行自动化的单元测试
以上就是python怎么增加矩阵维度的详细内容,更多请关注Gxl网其它相关文章!