Skip to content

Instantly share code, notes, and snippets.

@HViktorTsoi
Created September 3, 2018 11:55
Show Gist options
  • Save HViktorTsoi/38503be7eb67fcf6292aeb79dfd3fcd9 to your computer and use it in GitHub Desktop.
Save HViktorTsoi/38503be7eb67fcf6292aeb79dfd3fcd9 to your computer and use it in GitHub Desktop.
numpy shuffle一个或多个有对应关系的矩阵
X Y是二维的numpy矩阵
permutation = list(np.random.permutation(m))
shuffled_X = X[:, permutation]
shuffled_Y = Y[:, permutation].reshape((1,m)) # reshape是为了保证矩阵不会自动转化为向量
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment