f0nzie
9/7/2017 - 12:32 AM

Convert a 3D array to a column vector

Convert a 3D array to a column vector

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