Add backprop and add some comments

pull/8995/head
l00591931 4 years ago
parent d9b4b5c750
commit 9c6eb9b9a4

@ -609,7 +609,7 @@ class Interpolate(Cell):
scale_factor * width)' in float32
Supported Platforms:
``Ascend``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> from mindspore.ops import operations as P
@ -703,7 +703,7 @@ class Tril(Cell):
Tensor, has the same type as input `x`.
Supported Platforms:
``Ascend``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> x = Tensor(np.array([[1, 2], [3, 4]]))
@ -742,10 +742,13 @@ class Triu(Cell):
Outputs:
Tensor, has the same type as input `x`.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> x = Tensor(np.array([[1, 2], [3, 4]]))
>>> tril = nn.Tril()
>>> result = tril(x)
>>> triu = nn.Triu()
>>> result = triu(x)
>>> print(result)
[[1 2]
[0 4]]

@ -51,6 +51,36 @@ def get_bprop_fill(self):
return bprop
@bprop_getters.register(P.Ones)
def get_bprop_ones(self):
"""Generate bprop for Ones"""
def bprop(dims, dtype, out, dout):
return zeros_like(dims)
return bprop
@bprop_getters.register(P.Zeros)
def get_bprop_zeros(self):
"""Generate bprop for Zeros"""
def bprop(dims, dtype, out, dout):
return zeros_like(dims)
return bprop
@bprop_getters.register(P.SequenceMask)
def get_bprop_sequence_mask(self):
"""Generate bprop for SequenceMask"""
def bprop(lengths, dtype, max_length, out, dout):
return zeros_like(dims), zeros_like(max_length)
return bprop
@bprop_getters.register(P.DType)
def get_bprop_dtype(self):
"""Generate bprop for DType"""

@ -1136,7 +1136,7 @@ class Ones(PrimitiveWithInfer):
Tensor, has the same type and shape as input shape value.
Supported Platforms:
``Ascend`` ``GPU``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> from mindspore.ops import operations as ops
@ -1189,7 +1189,7 @@ class Zeros(PrimitiveWithInfer):
Tensor, has the same type and shape as input shape value.
Supported Platforms:
``Ascend`` ``GPU``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> from mindspore.ops import operations as ops
@ -1248,6 +1248,9 @@ class SequenceMask(PrimitiveWithInfer):
If max_length is not set and the biggest value in lengths is x. Then, the shape of
the output is (lengths.shape, x).
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> from mindspore.ops import operations as P
>>> sequence_mask = P.SequenceMask()

Loading…
Cancel
Save