numpy.broadcast_shapes#
- numpy.broadcast_shapes(*args)[源代码]#
将输入形状广播为单个形状.
Learn more about broadcasting here .
在 1.20.0 版本加入.
- 参数:
- args整数元组,或整数
要相互广播的形状.
- 返回:
- 元组
广播后的形状.
- 提出:
- ValueError
如果形状不兼容并且无法根据 NumPy 的广播规则进行广播.
示例
>>> import numpy as np >>> np.broadcast_shapes((1, 2), (3, 1), (3, 2)) (3, 2)
>>> np.broadcast_shapes((6, 7), (5, 6, 1), (7,), (5, 1, 7)) (5, 6, 7)