python3 reshape 小技巧

来源:互联网 发布:常德seo 编辑:程序博客网 时间:2024/05/22 10:30

        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)
原创粉丝点击