`np.stack` with equivalent implementation for torch. Args: x: array/tensor. dim: dimension along which to perform the stack (referred to as `axis` by numpy).
(x: Sequence[NdarrayTensor], dim: int)
| 412 | |
| 413 | |
| 414 | def stack(x: Sequence[NdarrayTensor], dim: int) -> NdarrayTensor: |
| 415 | """`np.stack` with equivalent implementation for torch. |
| 416 | |
| 417 | Args: |
| 418 | x: array/tensor. |
| 419 | dim: dimension along which to perform the stack (referred to as `axis` by numpy). |
| 420 | """ |
| 421 | if isinstance(x[0], np.ndarray): |
| 422 | return np.stack(x, dim) # type: ignore |
| 423 | return torch.stack(x, dim) # type: ignore |
| 424 | |
| 425 | |
| 426 | def mode(x: NdarrayTensor, dim: int = -1, to_long: bool = True) -> NdarrayTensor: |
no outgoing calls
searching dependent graphs…