mindspore.ops.AssignSub

class mindspore.ops.AssignSub[源代码]

从网络参数减去特定数值来更新网络参数。

更多细节请参考 mindspore.ops.assign_sub()

支持平台:

Ascend GPU CPU

样例:

>>> class Net(nn.Cell):
...     def __init__(self):
...         super(Net, self).__init__()
...         self.AssignSub = ops.AssignSub()
...         self.variable = mindspore.Parameter(initializer(1, [1], mindspore.int32), name="global_step")
...
...     def construct(self, x):
...         self.AssignSub(self.variable, x)
...         return self.variable
...
>>> net = Net()
>>> value = Tensor(np.ones([1]).astype(np.int32)*100)
>>> output = net(value)
>>> print(net.variable.asnumpy())
[-99]