expand_as¶
- paddle. expand_as ( x, y, name=None ) [source]
-
Expand the input tensor
xto the same shape as the input tensory.Both the number of dimensions of
xandymust be less than or equal to 6, and the number of dimensions ofymust be greather than or equal to that ofx. The dimension to expand must have a value of 1.- 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
-
A Tensor with the same shape as
y. The data type is the same asx. - Return type
-
N-D Tensor
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) np_out = out.numpy() # [[1, 2, 3], [1, 2, 3]]
