# expand_as¶

`paddle.fluid.layers.``expand_as`(x, target_tensor, name=None)[源代码]

```输入(x) 是一个形状为[2, 3, 1]的 3-D Tensor :

[
[[1], [2], [3]],
[[4], [5], [6]]
]

target_tensor的维度 :  [2, 6, 2]

[
[[1, 1], [2, 2], [3, 3], [1, 1], [2, 2], [3, 3]],
[[4, 4], [5, 5], [6, 6], [4, 4], [5, 5], [6, 6]]
]
```

## 参数¶

• x （Variable）- 维度最高为6的多维 `Tensor``LoDTensor`，数据类型为 `float32``float64``int32``bool`
• target_tensor （list|tuple|Variable）- 数据类型为 `float32``float64``int32``bool` 。可为Tensor或者LODTensor。
• name （str，可选）- 具体用法请参见 Name ，一般无需设置。默认值： `None`

## 返回类型¶

`Variable`

## 抛出异常¶

• `ValueError``target_tensor` 对应的每一维必须能整除输入x中对应的维度，否则会报错。

## 代码示例¶

```import paddle.fluid as fluid
import numpy as np
data = fluid.data(name="data", shape=[-1,10], dtype='float64')
target_tensor = fluid.data(name="target_tensor", shape=[-1,20], dtype='float64')
result = fluid.layers.expand_as(x=data, target_tensor=target_tensor)
use_cuda = False
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
x = np.random.rand(3,10)
y = np.random.rand(3,20)
output= exe.run(feed={"data":x,"target_tensor":y},fetch_list=[result.name])
print(output[0].shape)
#(3,20)
```