-
Notifications
You must be signed in to change notification settings - Fork 6k
fix docs #27637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix docs #27637
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,41 +213,37 @@ def flatten(x, start_axis=0, stop_axis=-1, name=None): | |
| Out.shape = (3 * 100 * 100 * 4) | ||
|
|
||
| Args: | ||
| x (Variable): A tensor of number of dimentions >= axis. A tensor with data type float32, | ||
| x (Tensor): A tensor of number of dimentions >= axis. A tensor with data type float32, | ||
| float64, int8, int32, int64. | ||
| start_axis (int): the start axis to flatten | ||
| stop_axis (int): the stop axis to flatten | ||
| name(str, Optional): For details, please refer to :ref:`api_guide_Name`. | ||
| Generally, no setting is required. Default: None. | ||
|
|
||
| Returns: | ||
| Variable: A tensor with the contents of the input tensor, with input \ | ||
| Tensor: A tensor with the contents of the input tensor, with input \ | ||
| axes flattened by indicated start axis and end axis. \ | ||
| A Tensor with data type same as input x. | ||
|
|
||
| Raises: | ||
| ValueError: If x is not a Variable. | ||
| ValueError: If x is not a Tensor. | ||
| ValueError: If start_axis or stop_axis is illegal. | ||
|
|
||
| Examples: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import paddle | ||
| import numpy as np | ||
|
|
||
| paddle.disable_static() | ||
|
|
||
| image_shape=(2, 3, 4, 4) | ||
| x = np.arange(image_shape[0] * image_shape[1] * image_shape[2] * image_shape[3]).reshape(image_shape) / 100. | ||
| x = x.astype('float32') | ||
| x = paddle.arange(end=image_shape[0] * image_shape[1] * image_shape[2] * image_shape[3]) | ||
| img = paddle.reshape(x, image_shape) / 100 | ||
|
||
|
|
||
| img = paddle.to_tensor(x) | ||
| out = paddle.flatten(img, start_axis=1, stop_axis=2) | ||
| # out shape is [2, 12, 4] | ||
| """ | ||
| if not (isinstance(x, Variable)): | ||
| raise ValueError("The input x should be a Variable") | ||
| raise ValueError("The input x should be a Tensor") | ||
|
|
||
| check_variable_and_dtype( | ||
| x, 'x', ['float32', 'float64', 'int8', 'int32', 'int64'], 'flatten') | ||
|
|
@@ -297,20 +293,18 @@ def roll(x, shifts, axis=None, name=None): | |
| the tensor will be flattened before rolling and then restored to the original shape. | ||
|
|
||
| Args: | ||
| x (Variable): The x tensor variable as input. | ||
| x (Tensor): The x tensor variable as input. | ||
| shifts (int|list|tuple): The number of places by which the elements | ||
| of the `x` tensor are shifted. | ||
| axis (int|list|tuple|None): axis(axes) along which to roll. | ||
|
|
||
| Returns: | ||
| Variable: A Tensor with same data type as `x`. | ||
| Tensor: A Tensor with same data type as `x`. | ||
|
|
||
| Examples: | ||
| .. code-block:: python | ||
| import paddle | ||
| import paddle.fluid as fluid | ||
|
|
||
| paddle.disable_static() | ||
| x = paddle.to_tensor([[1.0, 2.0, 3.0], | ||
| [4.0, 5.0, 6.0], | ||
| [7.0, 8.0, 9.0]]) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用加alias_main tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我删掉