flatten¶
dragon.
flatten
(
inputs,
axis=0,
end_axis=- 1,
copy=True,
**kwargs
)[source]¶Flatten the input along the given axes.
Set
keep_axes
to flatten if shape is dynamic.Examples:
x = dragon.ones((1, 2, 3, 4)) print(dragon.flatten(x, axis=1).shape) # (1, 24) print(dragon.flatten(x, axis=1, end_axis=2).shape) # (1, 6, 4)
- Parameters:
- inputs (dragon.Tensor) – The input tensor.
- axis (int, optional, default=0) – The first axis to flatten.
- end_axis (int, optional, default=-1) – The last axis to flatten.
- copy (bool, optional, default=True) – Return a new tensor or call in-place.
- Returns:
dragon.Tensor – The output tensor.