expand_as¶
- paddle. expand_as ( x, y, name=None ) [source]
-
Expand the input tensor
x
to the same shape as the input tensory
.Both the number of dimensions of
x
andy
must be less than or equal to 6, and the number of dimensions ofy
must be greater than or equal to that ofx
. The dimension to expand must have a value of 0.- Parameters
-
x (Tensor) – The input tensor, its data type is bool, float32, float64, int32 or int64.
y (Tensor) – The input tensor that gives the shape to expand to.
name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.
- Returns
-
N-D Tensor, A Tensor with the same shape as
y
. The data type is the same asx
.
Examples
>>> import paddle >>> data_x = paddle.to_tensor([1, 2, 3], 'int32') >>> data_y = paddle.to_tensor([[1, 2, 3], [4, 5, 6]], 'int32') >>> out = paddle.expand_as(data_x, data_y) >>> print(out) Tensor(shape=[2, 3], dtype=int32, place=Place(cpu), stop_gradient=True, [[1, 2, 3], [1, 2, 3]])