numpy.broadcast_shapes

numpy.broadcast_shapes(*args)[源代码]

将输入形状广播到单个形状中。

Learn more about broadcasting here .

1.20.0 新版功能.

参数
`*args`整数元组

要相互广播的形状。

返回
元组

广播形状。

加薪
ValueError

如果形状不兼容并且无法根据NumPy的广播规则进行广播。

实例

>>> 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)