megengine.functional.expand_dims

expand_dims(inp, axis)[source]

Adds dimension before given axis.

Parameters
Return type

Tensor

Returns

output tensor.

Examples

>>> import numpy as np
>>> x = Tensor([1, 2])
>>> out = F.expand_dims(x, 0)
>>> out.numpy().shape
(1, 2)