mindspore/docs/api/api_python/ops/mindspore.ops.func_derivati...

26 lines
1.1 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.derivative
========================
.. py:function:: mindspore.ops.derivative(fn, primals, order)
计算函数或网络输出对输入的高阶微分。给定待求导函数的原始输入和求导的阶数n将返回函数输出对输入的第n阶导数。输入的初始1阶导数在内部默认设置为1其他阶设置为0。
.. note::
-`primals` 是int型的Tensor会被转化成float32格式进行计算。
参数:
- **fn** (Union[Cell, function]) - 待求导的函数或网络。
- **primals** (Union[Tensor, tuple[Tensor]]) - `fn` 的输入单输入的type为Tensor多输入的type为Tensor组成的tuple。
- **order** (int) - 求导的阶数。
返回:
tuple`out_primals``out_series` 组成。
- **out_primals** (Union[Tensor, list[Tensor]]) - `fn(primals)` 的结果。
- **out_series** (Union[Tensor, list[Tensor]]) - `fn` 输出对输入的第n阶导数。
异常:
- **TypeError** - `primals` 不是Tensor或tuple。
- **TypeError** - `order` 不是int。
- **ValueError** - `order` 不是正数。