未验证 提交 d92daae2 编写于 作者: V Vvsmile 提交者: GitHub

Remove API: crop (#47972)

remove crop which is not used in Paddle 2.0
上级 3ca7328f
...@@ -124,7 +124,6 @@ __all__ = [ ...@@ -124,7 +124,6 @@ __all__ = [
'mean_iou', 'mean_iou',
'relu', 'relu',
'log', 'log',
'crop',
'crop_tensor', 'crop_tensor',
'pow', 'pow',
'hard_sigmoid', 'hard_sigmoid',
...@@ -9137,108 +9136,6 @@ def mean_iou(input, label, num_classes): ...@@ -9137,108 +9136,6 @@ def mean_iou(input, label, num_classes):
return out_mean_iou, out_wrong, out_correct return out_mean_iou, out_wrong, out_correct
def crop(x, shape=None, offsets=None, name=None):
"""
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 :ref:`api_fluid_layers_crop_tensor` instead.
.. code-block:: text
* 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, optional): 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, optional): 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 :ref:`api_guide_Name` . Usually name is no need to set and
None by default.
Returns:
Tensor, The cropped Tensor, which has the same rank and data type with `x`.
Examples:
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid as fluid
import paddle
paddle.enable_static()
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])
"""
check_variable_and_dtype(x, 'x', ['float32'], 'crop')
check_type(shape, 'shape', (list, tuple, Variable), 'crop')
helper = LayerHelper('crop', **locals())
if offsets is None:
offsets = [0] * len(x.shape)
out = helper.create_variable_for_type_inference(x.dtype)
ipts = {'X': x}
attrs = {}
if isinstance(shape, Variable):
ipts['Y'] = shape
else:
attrs['shape'] = shape
if isinstance(offsets, Variable):
ipts['Offsets'] = offsets
else:
attrs['offsets'] = offsets
helper.append_op(
type='crop',
inputs=ipts,
outputs={'Out': out},
attrs=None if len(attrs) == 0 else attrs,
)
return out
def crop_tensor(x, shape=None, offsets=None, name=None): def crop_tensor(x, shape=None, offsets=None, name=None):
""" """
Crop input into output, as specified by offsets and shape. Crop input into output, as specified by offsets and shape.
......
...@@ -3588,15 +3588,6 @@ class TestBook(LayerTest): ...@@ -3588,15 +3588,6 @@ class TestBook(LayerTest):
output = layers.l2_normalize(x, axis=1) output = layers.l2_normalize(x, axis=1)
return output return output
def make_crop(self):
with program_guard(
fluid.default_main_program(), fluid.default_startup_program()
):
x = self._get_data(name='x', shape=[3, 5], dtype="float32")
y = self._get_data(name='y', shape=[2, 3], dtype="float32")
output = layers.crop(x, shape=y)
return output
def make_mean_iou(self): def make_mean_iou(self):
with fluid.framework._dygraph_place_guard(place=fluid.CPUPlace()): with fluid.framework._dygraph_place_guard(place=fluid.CPUPlace()):
x = self._get_data(name='x', shape=[16], dtype='int32') x = self._get_data(name='x', shape=[16], dtype='int32')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册