当前位置:网站首页>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
边栏推荐
- Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
- Why do many people misunderstand technical debt
- 3.基金的类型
- 深入解析Kubebuilder
- 史上最全学习率调整策略lr_scheduler
- Some understandings about 01 backpacker
- Ansible reports an error: "MSG": "invalid/incorrect password: permission denied, please try again“
- npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
- Organize five stages of actual attack and defense drill
- npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
猜你喜欢

How to design API interface and realize unified format return?

Section 1: (3) logic chip process substrate selection

Sublime tips

Why do many people misunderstand technical debt

JS also exports Excel

LabVIEW在打开一个新的引用,提示内存已满

DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)

A simple and beautiful regression table is produced in one line of code~

Ansible概述和模块解释(你刚走过了今天,而扑面而来的却是昨天)

Markdown编辑器
随机推荐
一文搞懂常见的网络I/O模型
Introduction to namespace Basics
Using thread class and runnable interface to realize the difference between multithreading
Read of shell internal value command
U++ 游戏类 学习笔记
A simple and beautiful regression table is produced in one line of code~
装饰器基础学习02
Two methods of chromosome coordinate sequencing
高数中值定理总结
Some understandings about 01 backpacker
Ansible overview and module explanation (you just passed today, but yesterday came to your face)
【數模】Matlab allcycles()函數的源代碼(2021a之前版本沒有)
npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
Batch normalization (Standardization) processing
3. Type of fund
Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
NiO related knowledge points (I)
U++ 元数据说明符 学习笔记
01 machine learning related regulations