fill_diagonal_¶
- paddle.Tensor. fill_diagonal_ ( x, value, offset=0, wrap=False, name=None )
-
Note
This API is ONLY available in Dygraph mode.
This function fill the value into the x Tensor’s diagonal inplace.
- Parameters
-
x (Tensor) –
x
is the original Tensorvalue (Scale) –
value
is the value to filled in xoffset (int,optional) – the offset to the main diagonal. Default: 0 (main diagonal).
wrap (bool,optional) – the diagonal ‘wrapped’ after N columns for tall matrices.
name (str,optional) – Name for the operation (optional, default is None)
- Returns
-
Tensor, Tensor with diagonal filled with value.
Examples
>>> 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]]