• np.zeros np.randint np.multiply


    1.np.zeros()该函数返回一个ndarray。输出数组是具有指定形状, dtype, order并包含零的数组。

    import numpy as np
    a=np.zeros(6,)
    a

    输出

    array([0., 0., 0., 0., 0., 0.])

    2.

    函数功能:
    Return random integers from low (inclusive) to high (exclusive)。
    Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low)。
    返回最小值(包含)与最大值(不包含)之间的随机整数。
    具体是:返回半开区间(前闭后开)上指定数据类型的服从离散均匀分布的随机整数。若最大值为空,默认返回[0,low)之间服从均匀分布的随机数

    函数语法:

    numpy.random.randint(low, high=None, size=None, dtype=int)

    函数参数:
    low: int or array-like of ints。Lowest (signed) integers to be drawn from the distribution (unless high=None, in which case this parameter is one above the highest such integer).
    最小值:整数或整数形式的数组。分布中的最小整数值(含正负号。若high为空则,该值比分布中产生的最大值大1。

    high: int or array-like of ints, optional。If provided, one above the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None). If array-like, must contain integer values
    **最大值:**可选参数,整数或整数形式的数组。若函数中给定,则比分布函数中产生的最大值大1。若为整数形式的数组,则必须包含整数值。(不理解)

    size: int or tuple of ints, optional。Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.
    **大小:**可选参数,整数或者整数元组,若以(m,n,k)的形式给定大小则从分布函数中产生m ∗ n ∗ k m*n*kmnk个样本值。默认为空,此时返回单个样本值。

    dtype: dtype, optional。Desired dtype of the result. Byteorder must be native. The default value is int.
    数据类型: 可选参数,所需要的结果数据类型,默认整数型。

    3.print ('两个数组相乘:') print (np.multiply(a,b)).     https://www.runoob.com/numpy/numpy-arithmetic-operations.html

    第一个数组:
    [[0. 1. 2.]
     [3. 4. 5.]
     [6. 7. 8.]]
    
    
    第二个数组:
    [10 10 10]
    
    
    两个数组相乘:
    [[ 0. 10. 20.]
     [30. 40. 50.]
     [60. 70. 80.]]
    
    
    
  • 相关阅读:
    slf4j+log4j2的配置
    日志规约
    log4j2配置文件log4j2.xml详解(转载)
    好用的打包工具webpack
    gulp插件
    学习自动化工具gulp
    git
    nodejs学习随笔
    好用的meta标签
    小问题记录
  • 原文地址:https://www.cnblogs.com/h694879357/p/16013747.html
Copyright © 2020-2023  润新知