mindspore.ops.AddN

class mindspore.ops.AddN[源代码]

逐元素将所有输入的Tensor相加。

更多参考详见 mindspore.ops.addn()

支持平台:

Ascend GPU CPU

样例:

>>> class NetAddN(nn.Cell):
...     def __init__(self):
...         super(NetAddN, self).__init__()
...         self.addN = ops.AddN()
...
...     def construct(self, *z):
...         return self.addN(z)
...
>>> net = NetAddN()
>>> x = Tensor(np.array([1, 2, 3]), mindspore.float32)
>>> y = Tensor(np.array([4, 5, 6]), mindspore.float32)
>>> output = net(x, y, x, y)
>>> print(output)
[10. 14. 18.]