The following command flattens out all except the last dimension of an n-d array; useful, for example, to create a feature vector.
W_flat = W.reshape((-1,W.shape[-1]))
Last active
November 29, 2017 20:29
-
-
Save arshednabeel/c1811d02a8c64e7874f0310292c47c37 to your computer and use it in GitHub Desktop.
NumPy Noob Trick: Flatten out all except the last dimension of an ndarray.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment