update document of NMSWithMask

pull/14445/head
liuhe 4 years ago
parent ddf75da542
commit 9d2de1596f

@ -3747,8 +3747,14 @@ class Asin(PrimitiveWithInfer):
class NMSWithMask(PrimitiveWithInfer): class NMSWithMask(PrimitiveWithInfer):
""" r"""
Selects some bounding boxes in descending order of score. When object detection problem is performed in the computer vision field, object detection algorithm generates
a plurality of bounding boxes. Selects some bounding boxes in descending order of score. Use the box with the
highest score calculate the overlap between other boxes and the current box, and delete the box based on a
certain threshold(IOU). The IOU is as follows,
.. math::
\text{IOU} = \frac{\text{Area of Overlap}}{\text{Area of Union}}
Args: Args:
iou_threshold (float): Specifies the threshold of overlap boxes with respect to iou_threshold (float): Specifies the threshold of overlap boxes with respect to
@ -3781,7 +3787,7 @@ class NMSWithMask(PrimitiveWithInfer):
Examples: Examples:
>>> bbox = np.array([[100.0, 100.0, 50.0, 68.0, 0.63], [150.0, 75.0, 165.0, 115.0, 0.55], >>> bbox = np.array([[100.0, 100.0, 50.0, 68.0, 0.63], [150.0, 75.0, 165.0, 115.0, 0.55],
[12.0, 190.0, 288.0, 200.0, 0.9], [28.0, 130.0, 106.0, 172.0, 0.3]]) ... [12.0, 190.0, 288.0, 200.0, 0.9], [28.0, 130.0, 106.0, 172.0, 0.3]])
>>> bbox[:, 2] += bbox[:, 0] >>> bbox[:, 2] += bbox[:, 0]
>>> bbox[:, 3] += bbox[:, 1] >>> bbox[:, 3] += bbox[:, 1]
>>> inputs = Tensor(bbox, mindspore.float32) >>> inputs = Tensor(bbox, mindspore.float32)

@ -4439,7 +4439,7 @@ class FusedSparseAdam(PrimitiveWithInfer):
>>> epsilon = Tensor(1e-8, mstype.float32) >>> epsilon = Tensor(1e-8, mstype.float32)
>>> gradient = Tensor(np.random.rand(2, 1, 2), mstype.float32) >>> gradient = Tensor(np.random.rand(2, 1, 2), mstype.float32)
>>> indices = Tensor([0, 1], mstype.int32) >>> indices = Tensor([0, 1], mstype.int32)
>>> net(beta1_power, beta2_power, lr, beta1, beta2, epsilon, gradient, indices) >>> output = net(beta1_power, beta2_power, lr, beta1, beta2, epsilon, gradient, indices)
>>> print(net.var.asnumpy()) >>> print(net.var.asnumpy())
[[[0.9996963 0.9996977 ]] [[[0.9996963 0.9996977 ]]
[[0.99970144 0.9996992 ]] [[0.99970144 0.9996992 ]]
@ -4587,7 +4587,7 @@ class FusedSparseLazyAdam(PrimitiveWithInfer):
>>> epsilon = Tensor(1e-8, mstype.float32) >>> epsilon = Tensor(1e-8, mstype.float32)
>>> gradient = Tensor(np.random.rand(2, 1, 2), mstype.float32) >>> gradient = Tensor(np.random.rand(2, 1, 2), mstype.float32)
>>> indices = Tensor([0, 1], mstype.int32) >>> indices = Tensor([0, 1], mstype.int32)
>>> net(beta1_power, beta2_power, lr, beta1, beta2, epsilon, gradient, indices) >>> output = net(beta1_power, beta2_power, lr, beta1, beta2, epsilon, gradient, indices)
>>> print(net.var.asnumpy()) >>> print(net.var.asnumpy())
[[[0.9996866 0.9997078]] [[[0.9996866 0.9997078]]
[[0.9997037 0.9996869]] [[0.9997037 0.9996869]]

@ -270,10 +270,10 @@ class PrimitiveWithCheck(Primitive):
... pass ... pass
... def check_shape(self, input_x): ... def check_shape(self, input_x):
... validator.check_int(len(input_x), 1, Rel.GE, 'input_x rank', self.name) ... validator.check_int(len(input_x), 1, Rel.GE, 'input_x rank', self.name)
>>> ...
... def check_dtype(self, input_x): ... def check_dtype(self, input_x):
... validator.check_subclass("input_x", input_x, mstype.tensor, self.name) ... validator.check_subclass("input_x", input_x, mstype.tensor, self.name)
>>> ...
>>> # init a Primitive obj >>> # init a Primitive obj
>>> add = Flatten() >>> add = Flatten()
""" """
@ -348,13 +348,13 @@ class PrimitiveWithInfer(Primitive):
... @prim_attr_register ... @prim_attr_register
... def __init__(self): ... def __init__(self):
... pass ... pass
>>> ...
... def infer_shape(self, x, y): ... def infer_shape(self, x, y):
... return x # output shape same as first input 'x' ... return x # output shape same as first input 'x'
>>> ...
... def infer_dtype(self, x, y): ... def infer_dtype(self, x, y):
... return x # output type same as first input 'x' ... return x # output type same as first input 'x'
>>> ...
>>> # init a Primitive obj >>> # init a Primitive obj
>>> add = Add() >>> add = Add()
""" """

Loading…
Cancel
Save