MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / squeeze

Function squeeze

imperative/python/megengine/functional/tensor.py:1070–1087  ·  view source on GitHub ↗

r"""Removes dimension of shape 1. Args: inp: input tensor. axis: place of axis to be removed. Returns: output tensor. Examples: >>> import numpy as np >>> x = Tensor(np.array([1, 2], dtype=np.int32).reshape(1, 1, 2, 1)) >>> out = F.squee

(inp: Tensor, axis: Optional[Union[int, Sequence[int]]] = None)

Source from the content-addressed store, hash-verified

1068
1069
1070def squeeze(inp: Tensor, axis: Optional[Union[int, Sequence[int]]] = None) -> Tensor:
1071 r"""Removes dimension of shape 1.
1072
1073 Args:
1074 inp: input tensor.
1075 axis: place of axis to be removed.
1076
1077 Returns:
1078 output tensor.
1079
1080 Examples:
1081 >>> import numpy as np
1082 >>> x = Tensor(np.array([1, 2], dtype=np.int32).reshape(1, 1, 2, 1))
1083 >>> out = F.squeeze(x, 3)
1084 >>> out.numpy().shape
1085 (1, 1, 2)
1086 """
1087 return squeeze_cpp(inp, axis)
1088
1089
1090def repeat(inp: Tensor, repeats: int, axis: Optional[int] = None):

Callers 6

calc_bmm_quantizedMethod · 0.85
logsumexpFunction · 0.85
indexing_one_hotFunction · 0.85
argminFunction · 0.85
argmaxFunction · 0.85
topkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected