fill_diagonal_

paddle.Tensor. fill_diagonal_ ( x, value, offset=0, wrap=False, name=None )
Notes:

This API is ONLY available in Dygraph mode

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/tensor/manipulation.py:docstring of paddle.tensor.manipulation.fill_diagonal_, line 3)

Definition list ends without a blank line; unexpected unindent.

This function fill the value into the x Tensor’s diagonal inplace. :param x: x is the original Tensor :type x: Tensor :param value: value is the value to filled in x :type value: Scale :param offset: the offset to the main diagonal. Default: 0 (main diagonal). :type offset: int,optional :param wrap: the diagonal ‘wrapped’ after N columns for tall matrices. :type wrap: bool,optional :param name: Name for the operation (optional, default is None) :type name: str,optional

Returns

Tensor with diagonal filled with value.

Return type

Tensor

Returns type:

dtype is same as x Tensor

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/tensor/manipulation.py:docstring of paddle.tensor.manipulation.fill_diagonal_, line 20)

Definition list ends without a blank line; unexpected unindent.

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/tensor/manipulation.py:docstring of paddle.tensor.manipulation.fill_diagonal_, line 22)

Error in “code-block” directive: maximum 1 argument(s) allowed, 23 supplied.

.. code-block:: python
    import paddle
    x = paddle.ones((4, 3)) * 2
    x.fill_diagonal_(1.0)
    print(x.tolist())   #[[1.0, 2.0, 2.0], [2.0, 1.0, 2.0], [2.0, 2.0, 1.0], [2.0, 2.0, 2.0]]