resize_
- paddle.Tensor. resize_ ( x: paddle.Tensor, shape: Sequence[int], fill_zero: bool = False, name: str | None = None ) paddle.Tensor
-
Resize
xwith specifiedshape.- Parameters
-
x (Tensor) – An arbitrary Tensor. The data type supports
bfloat16,float16,float32,float64,bool,int8,int16,int32,int64,uint8,complex64orcomplex128.shape (list|tuple) – Define the target shape. Each element of it should be integer.
fill_zero (bool, optional) – If the size of specified
shapeis greater than the original Tensor size, the new Tensor will be filled with zero iffill_zerois True. Default: False, which means the filled value will be undetermined.name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to api_guide_Name.
- Returns
-
Tensor, the resized Tensor.
Examples
>>> import paddle >>> x = paddle.to_tensor([1., 2., 3.]) >>> x.resize_([2, 1]) >>> print(x) Tensor(shape=[2, 1], dtype=float32, place=Place(cpu), stop_gradient=True, [[1.], [2.]]) >>> x = paddle.to_tensor([1., 2., 3.]) >>> x.resize_([2, 3], fill_zero=True) >>> print(x) Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True, [[1., 2., 3.], [0., 0., 0.]])
