mindspore.ops.AssignAdd
- class mindspore.ops.AssignAdd[源代码]
进行加法运算更新网络参数。
更多细节请参考
mindspore.ops.assign_add()
。- 支持平台:
Ascend
GPU
CPU
样例:
>>> class Net(nn.Cell): ... def __init__(self): ... super(Net, self).__init__() ... self.AssignAdd = ops.AssignAdd() ... self.variable = mindspore.Parameter(initializer(1, [1], mindspore.int64), name="global_step") ... ... def construct(self, x): ... self.AssignAdd(self.variable, x) ... return self.variable ... >>> net = Net() >>> value = Tensor(np.ones([1]).astype(np.int64)*100) >>> output = net(value) >>> print(net.variable.asnumpy()) [101]