当前位置:网站首页>np. random. Shuffle and np Use swapaxis or transfer with caution

np. random. Shuffle and np Use swapaxis or transfer with caution

2022-07-07 05:17:00 Fun of construction

  # y = np.transpose(y,(1,0,2))

  # y = np.random.shuffle(y)

  # y = np.transpose(y,(1,0,2))

These three lines of code will lead to ValueError: axes don't match array Error of ,
Similarly, , If you use swapaxis–shuffle–swapaxis Similar errors will occur .
Avoid this problem .
And if you want to arrange a dimension randomly , have access to permutation+ Slicing scheme ,shuffle Just for axis 0 Random .

reference

https://www.cnblogs.com/zmbreathing/p/random_shuffle.html

原网站

版权声明
本文为[Fun of construction]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207062249120239.html