# crop¶

`paddle.fluid.layers.``crop`(x, shape=None, offsets=None, name=None)[source]

Crop input into output, as specified by offsets and shape.

Warning: THIS OP IS DEPRECATED. It will be removed in the future version. Instructions for updating: Use crop_tensor instead.

```* Case 1:
Given
X = [[0, 1, 2, 0, 0]
[0, 3, 4, 0, 0]
[0, 0, 0, 0, 0]],
and
shape = [2, 2],
offsets = [0, 1],
output is:
Out = [[1, 2],
[3, 4]].
* Case 2:
Given
X = [[0, 1, 2, 5, 0]
[0, 3, 4, 6, 0]
[0, 0, 0, 0, 0]],
and shape is tensor
shape = [[0, 0, 0]
[0, 0, 0]]
and
offsets = [0, 1],

output is:
Out = [[1, 2, 5],
[3, 4, 6]].
```
Parameters
• x (Variable) – Tensor, data type can be float32 or float64.

• shape (Variable|list/tuple of integers) – The output shape is specified by shape, which can be a Tensor or a list/tuple of integers. If it is a Tensor, it’s rank must be the same as x , only it’s shape will be used, and the value of it will be ignored. This way is suitable for the case that the output shape may be changed each iteration. If it is a list/tuple of integers, it’s length must be the same as the rank of x

• offsets (Variable|list/tuple of integers|None) – Specifies the cropping offsets at each dimension. It can be a Tensor or a list/tuple of integers. If it is a Tensor, it’s rank must be the same as x. This way is suitable for the case that the offsets may be changed each iteration. If it is a list/tuple of integers, it’s length must be the same as the rank of x. If None, the offsets are 0 at each dimension.

• name (str, optional) – For detailed information, please refer to Name . Usually name is no need to set and None by default.

Returns

The cropped Tensor, which has the same rank and data type with x

Return Type:

Variable

Raises

`ValueError` – If shape is not a list, tuple or Variable.

Examples

```import paddle.fluid as fluid
x = fluid.data(name="x", shape=[3, 3, 5], dtype="float32")
y = fluid.data(name="y", shape=[2, 2, 3], dtype="float32")
crop = fluid.layers.crop(x, shape=y)

# or
z = fluid.data(name="z", shape=[3, 3, 5], dtype="float32")
crop = fluid.layers.crop(z, shape=[2, 2, 3])
```