python3 reshape 小技巧

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/hhsh49/article/details/78614728

        1 A trick when you want to flatten a matrix X of shape (a,b,c,d) to a matrix X_flatten of shape (bcd, a) is to use:

   X_flatten = X.reshape(X.shape[0], -1).T      # X.T is the transpose of X
2  for picture datasets, it is simpler and more convenient and works almost as well to just divide every row of the dataset by 255 (the maximum value of a pixel channel)

猜你喜欢

转载自blog.csdn.net/hhsh49/article/details/78614728