Skip to content

Instantly share code, notes, and snippets.

@f0nzie
Created September 7, 2017 00:32
Show Gist options
  • Save f0nzie/f523b0f3685caa73e887b273f080adef to your computer and use it in GitHub Desktop.
Save f0nzie/f523b0f3685caa73e887b273f080adef to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment