python 将3D数组转换为列向量

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 将3D数组转换为列向量相关的知识,希望对你有一定的参考价值。

def image2vector(image):
    """
    Argument:
    image -- a numpy array of shape (length, height, depth)
    
    Returns:
    v -- a vector of shape (length*height*depth, 1)
    """
    
    v = image.reshape((image.shape[0] * image.shape[1] * image.shape[2], 1))
    
    return v

以上是关于python 将3D数组转换为列向量的主要内容,如果未能解决你的问题,请参考以下文章