当前位置:网站首页>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
边栏推荐
- If you ask me about R code debugging, I will tell you head, STR, help
- 谈谈讲清楚这件事的重要性
- Servicemesh mainly solves three pain points
- npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
- Pointer and array are input in function to realize reverse order output
- DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
- Time complexity & space complexity
- 【Android Kotlin协程】利用CoroutineContext实现网络请求失败后重试逻辑
- PLC模拟量输出 模拟量输出FB analog2NDA(三菱FX3U)
- Function pointer and pointer function in C language
猜你喜欢
深入解析Kubebuilder
Monitoring cannot be started after Oracle modifies the computer name
Weebly mobile website editor mobile browsing New Era
[736. LISP syntax parsing]
动态生成表格
如何设计 API 接口,实现统一格式返回?
How to design API interface and realize unified format return?
Ansible报错:“msg“: “Invalid/incorrect password: Permission denied, please try again.“
Decorator basic learning 02
Error: No named parameter with the name ‘foregroundColor‘
随机推荐
app内嵌h5---iphone软键盘遮挡输入文字
【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析
Oracle -- 视图与序列
R descriptive statistics and hypothesis testing
npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
Tiktok may launch an independent grass planting community platform: will it become the second little red book
Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
Analysis -- MySQL statement execution process & MySQL architecture
Sublime tips
谈谈讲清楚这件事的重要性
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
Stm32f103ze+sht30 detection of ambient temperature and humidity (IIC simulation sequence)
Decorator basic learning 02
窗口可不是什么便宜的东西
Canteen user dish relationship system (C language course design)
R language principal component PCA, factor analysis, clustering analysis of regional economy analysis of Chongqing Economic Indicators
[hand torn STL] list
Leetcode longest public prefix
STM32F103ZE+SHT30检测环境温度与湿度(IIC模拟时序)
【数模】Matlab allcycles()函数的源代码(2021a之前版本没有)