1. numpy.random.shuffle(x)

Modify a sequence in-place by shuffling its contents.

This function only shuffles the array along the first axis of a multi-dimensional array. The order of sub-arrays is changed but their contents remains the same.

Parameters:
x : array_like. The array or list to be shuffled. Returns: None

注意:

  • 无返回值,改变原有 array
  • 对于多维 array,只 shuffle 第一维

2. numpy.random.permutation(x) 

Randomly permute a sequence, or return a permuted range.

If x is a multi-dimensional array, it is only shuffled along its first index.

Parameters:
x : int or array_like If x is an integer, randomly permute np.arange(x). If x is an array, make a copy and shuffle the elements randomly. Returns:
out : ndarray Permuted sequence or array range.

注意:

  • 跟 shuffle 的区别

    • 有返回值
    • 且不改变原来的 array,会生成一个新的 array
  • x 为整型时,先将 x 变成 array: np.arange(x),再打乱顺序

Numpy 随机序列 shuffle & permutation的更多相关文章

  1. numpy.random.shuffle()与numpy.random.permutation()的区别

    参考API:https://docs.scipy.org/doc/numpy/reference/routines.random.html 1. numpy.random.shuffle()   AP ...

  2. numpy.random.shuffle(x)的用法

    numpy.random.shuffle(x) Modify a sequence in-place by shuffling its contents. Parameters: x : array_ ...

  3. numpy的shuffle函数

    import numpy as np from numpy.random import shuffle import pandas as pd df = pd.DataFrame([[1,2,3],[ ...

  4. Matlab Tricks(二十六)—— 置乱(随机化)与恢复(shuffle/permutation & restore)

    x = 1:10; n = length(x); perm = randperm(n); x_perm = x(perm); % x_perm 表示置乱后的结果 x_ori(perm) = x_per ...

  5. numpy.random中的shuffle和permutation以及mini-batch调整数据集(X, Y)

    0. numpy.random中的shuffle和permutation numpy.random.shuffle(x) and numpy.random.permutation(x),这两个有什么不 ...

  6. numpy之random学习

    在机器学习中参数初始化需要进行随机生成,同时样本也需要随机生成,或者遵从一定规则随机生成,所以对随机生成的使用显得格外重要. 有的是生成随机数,有的是随机序列,有点是从随机序列中选择元素等等. 简单的 ...

  7. numpy.random 常用函数详解之排列乱序篇(Permutations)

    1.numpy.random.shuffle(x) 参数:填入数组或列表. 返回值:无. 函数功能描述:对填入的数组或列表进行乱序处理,shape保持不变. 2.numpy.random.permut ...

  8. np.random.random()函数 参数用法以及numpy.random系列函数大全

    原文作者:aircraft 原文链接:https://www.cnblogs.com/DOMLX/p/9751471.html 1.np.random.random()函数参数 np.random.r ...

  9. Python学习——numpy.random

    numpy.random.rand numpy.random模块作用是生成随机数,其中numpy.random.rand(d0, d1, ..., dn):生成一个[0,1)之间的随机浮点数或N维浮点 ...

随机推荐

  1. npm 使用过程中报错问题-及npm使用

    原文地址:https://blog.csdn.net/u013022210/article/details/77740519 1.以下为报错具体详情:node 8.1.2 版本问题:其他空间安装成功但 ...

  2. OGG For Oracle To PostgreSQL

    本文档描述OGG(Oracle goldengate)为Oracle同步到PostgreSQL数据库配置.在目前去“IOE”潮流.PostgreSQL确实是Oracle最好的替代品之一. 实验环境如下 ...

  3. hadoop搭建的前期准备

    这个hadoop的搭建是以比赛前的练习为目的的,所以我直接以root用户来搭建hadoop,主要也是方便我自己以后复习用的 需要的软件:vmware15.5,xshell6,xftp6,jdk Lin ...

  4. Test Case:: 12C ASMCMD New feature (Doc ID 1589249.1)

    Test Case:: 12C ASMCMD New feature (Doc ID 1589249.1) APPLIES TO: Oracle Database - Enterprise Editi ...

  5. (办公)记事本_Linux目录和文件都能操作的命令

    参考谷粒学院Linux:http://www.gulixueyuan.com/course/300/task/7082/show .cp 1.1.作用主要是拷贝,可以拷贝文件或者目录. 1.2.语法: ...

  6. SqlException:ConnectionTimeout Expired. The timeout period elapsed during the post-login phase

    linux系统部署.netcore程序后,访问某台sqlserver 2008 R2数据库 Connection Timeout Expired. The timeout period elapsed ...

  7. Ubuntu设置开机时启动的系统内核版本

    1.查看系统当前安装的所有内核版本 有两种方法 第一种: 可以查看/lib/modules下的文件夹,一个文件夹对应一个内核版本,如下图: 第二种:使用下面的命令查看: dpkg --get-sele ...

  8. Windows10+texlive2018+texstudio

    texlive2018+texstudio下载链接 链接: https://pan.baidu.com/s/1KjPJnw1kwMBCu3qGT9rIUg 提取码: g8ha 安装texlive 解压 ...

  9. 计算机网络知识(TCP连接,TCP/UDP区别,HTTP与HTTPS,Socket原理等等)

    1.网络七层协议包含,物理层.数据链路层.网络层(ip协议).传输层(TCP传输控制协议.UDP用户数据报协议).会话层.表示层.应用层(http协议).是一个提供的概念架构协议. 2.TCP/IP协 ...

  10. 爬虫最新的库requests-html库总结

    requests-html是比较新的爬虫库,作者和requests是同一个作者 一.安装依赖 pip install requests-html 我们可以在安装的时候看到他安装了lxml,reuqes ...