forked from mindspore-Ecosystem/mindspore
!25769 Fix document for Jvp and Vjp
Merge pull request !25769 from LiangZhibo/code_docs_master
This commit is contained in:
commit
b3c5b96c37
|
@ -55,9 +55,13 @@ class Jvp(Cell):
|
||||||
|
|
||||||
Outputs:
|
Outputs:
|
||||||
A tuple with 2 Tensors or Tuple of Tensors:
|
A tuple with 2 Tensors or Tuple of Tensors:
|
||||||
|
|
||||||
- **net_output** (Tensors or Tuple of Tensors) - The output of `network(inputs)`.
|
- **net_output** (Tensors or Tuple of Tensors) - The output of `network(inputs)`.
|
||||||
- **jvp** (Tensors or Tuple of Tensors) - The result of the jacobian vector product.
|
- **jvp** (Tensors or Tuple of Tensors) - The result of the jacobian vector product.
|
||||||
|
|
||||||
|
Supported Platforms:
|
||||||
|
``Ascend`` ``GPU`` ``CPU``
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
>>> from mindspore.nn import Jvp
|
>>> from mindspore.nn import Jvp
|
||||||
>>> class Net(nn.Cell):
|
>>> class Net(nn.Cell):
|
||||||
|
@ -67,6 +71,10 @@ class Jvp(Cell):
|
||||||
>>> y = Tensor(np.array([[1, 2], [3, 4]]).astype(np.float32))
|
>>> y = Tensor(np.array([[1, 2], [3, 4]]).astype(np.float32))
|
||||||
>>> v = Tensor(np.array([[1, 1], [1, 1]]).astype(np.float32))
|
>>> v = Tensor(np.array([[1, 1], [1, 1]]).astype(np.float32))
|
||||||
>>> output = Jvp(Net())(x, y, (v, v))
|
>>> output = Jvp(Net())(x, y, (v, v))
|
||||||
|
>>> print(output[0])
|
||||||
|
[[2, 10], [20, 68]]
|
||||||
|
>>> print(output[1])
|
||||||
|
[[4, 13], [28, 49]]
|
||||||
"""
|
"""
|
||||||
def __init__(self, fn):
|
def __init__(self, fn):
|
||||||
super(Jvp, self).__init__()
|
super(Jvp, self).__init__()
|
||||||
|
@ -119,9 +127,13 @@ class Vjp(Cell):
|
||||||
|
|
||||||
Outputs:
|
Outputs:
|
||||||
A tuple with 2 Tensors or Tuple of Tensors:
|
A tuple with 2 Tensors or Tuple of Tensors:
|
||||||
|
|
||||||
- **net_output** (Tensors or Tuple of Tensors) - The output of `network(inputs)`.
|
- **net_output** (Tensors or Tuple of Tensors) - The output of `network(inputs)`.
|
||||||
- **vjp** (Tensors or Tuple of Tensors) - The result of the dot product.
|
- **vjp** (Tensors or Tuple of Tensors) - The result of the dot product.
|
||||||
|
|
||||||
|
Supported Platforms:
|
||||||
|
``Ascend`` ``GPU`` ``CPU``
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
>>> from mindspore.nn import Vjp
|
>>> from mindspore.nn import Vjp
|
||||||
>>> class Net(nn.Cell):
|
>>> class Net(nn.Cell):
|
||||||
|
@ -131,6 +143,10 @@ class Vjp(Cell):
|
||||||
>>> y = Tensor(np.array([[1, 2], [3, 4]]).astype(np.float32))
|
>>> y = Tensor(np.array([[1, 2], [3, 4]]).astype(np.float32))
|
||||||
>>> v = Tensor(np.array([[1, 1], [1, 1]]).astype(np.float32))
|
>>> v = Tensor(np.array([[1, 1], [1, 1]]).astype(np.float32))
|
||||||
>>> output = Vjp(Net())(x, y, v)
|
>>> output = Vjp(Net())(x, y, v)
|
||||||
|
>>> print(output[0])
|
||||||
|
[[2, 10], [20, 68]]
|
||||||
|
>>> print(output[1])
|
||||||
|
([[3, 12], [27, 48]], [[1, 1], [1, 1]])
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, fn):
|
def __init__(self, fn):
|
||||||
|
|
Loading…
Reference in New Issue