r"""Adds dimension before given axis. Args: inp: input tensor. axis: place of new axes. Returns: output tensor. Examples: >>> import numpy as np >>> x = Tensor([1, 2]) >>> out = F.expand_dims(x, 0) >>> out.numpy().shape (
(inp: Tensor, axis: Union[int, Sequence[int]])
| 1047 | |
| 1048 | |
| 1049 | def expand_dims(inp: Tensor, axis: Union[int, Sequence[int]]) -> Tensor: |
| 1050 | r"""Adds dimension before given axis. |
| 1051 | |
| 1052 | Args: |
| 1053 | inp: input tensor. |
| 1054 | axis: place of new axes. |
| 1055 | |
| 1056 | Returns: |
| 1057 | output tensor. |
| 1058 | |
| 1059 | Examples: |
| 1060 | >>> import numpy as np |
| 1061 | >>> x = Tensor([1, 2]) |
| 1062 | >>> out = F.expand_dims(x, 0) |
| 1063 | >>> out.numpy().shape |
| 1064 | (1, 2) |
| 1065 | """ |
| 1066 | |
| 1067 | return expand_dims_cpp(inp, axis) |
| 1068 | |
| 1069 | |
| 1070 | def squeeze(inp: Tensor, axis: Optional[Union[int, Sequence[int]]] = None) -> Tensor: |
no outgoing calls