Skip to content

einops.asnumpy

Convert a tensor of an imperative framework (i.e. numpy/cupy/torch/gluon/etc.) to numpy.ndarray

Parameters:

Name Type Description Default
tensor

tensor of any of known imperative framework

required

Returns:

Type Description

numpy.ndarray, converted to numpy

Source code in einops/einops.py
def asnumpy(tensor):
    """
    Convert a tensor of an imperative framework (i.e. numpy/cupy/torch/gluon/etc.) to `numpy.ndarray`

    Parameters:
        tensor: tensor of any of known imperative framework

    Returns:
        `numpy.ndarray`, converted to numpy
    """
    return get_backend(tensor).to_numpy(tensor)