当前位置:网站首页>np.random.shuffle与np.swapaxis或transpose一起时要慎用
np.random.shuffle与np.swapaxis或transpose一起时要慎用
2022-07-06 22:49:00 【构建的乐趣】
# y = np.transpose(y,(1,0,2))
# y = np.random.shuffle(y)
# y = np.transpose(y,(1,0,2))
以上这三行代码会导致ValueError: axes don't match array
的错误,
无独有偶,如果使用swapaxis–shuffle–swapaxis也会出现类似的错误。
要避开这一问题。
而要想对某一维度随机排列,可以使用permutation+切片的方案,shuffle仅仅只对axis 0随机。
参考文献
https://www.cnblogs.com/zmbreathing/p/random_shuffle.html
边栏推荐
- Markdown编辑器
- Programmers go to work fishing, so play high-end!
- 窗口可不是什么便宜的东西
- Decorator basic learning 02
- Flask project uses flask socketio exception: typeerror: function() argument 1 must be code, not str
- U++4 接口 学习笔记
- sublime使用技巧
- Time complexity & space complexity
- Function pointer and pointer function in C language
- LabVIEW在打开一个新的引用,提示内存已满
猜你喜欢
Ansible概述和模块解释(你刚走过了今天,而扑面而来的却是昨天)
JS variable plus
sublime使用技巧
Flask project uses flask socketio exception: typeerror: function() argument 1 must be code, not str
3GPP信道模型路损基础知识
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
Error: No named parameter with the name ‘foregroundColor‘
Decorator basic learning 02
Time complexity & space complexity
Oracle -- 视图与序列
随机推荐
指针与数组在函数中输入实现逆序输出
Some understandings about 01 backpacker
3.基金的类型
Comparison between thread and runnable in creating threads
Leetcode notes
Why is the salary of test and development so high?
Flask project uses flask socketio exception: typeerror: function() argument 1 must be code, not str
Introduction to namespace Basics
JS also exports Excel
3. Type of fund
A row of code r shows the table of Cox regression model
Introduction to the PureMVC series
[line segment tree practice] recent requests + area and retrieval - array modifiable + my schedule I / III
全国气象数据/降雨量分布数据/太阳辐射数据/NPP净初级生产力数据/植被覆盖度数据
JS variable case
Common Oracle SQL statements
Markdown editor
Terms used in the Web3 community
STM32F103ZE+SHT30检测环境温度与湿度(IIC模拟时序)
ServiceMesh主要解决的三大痛点