• Numpy Notes


    np.linalg.norm()

    Matrix or vector norm
    return one of eight different matrix norms, or one of an infinite number of vector norms (described below), depending on the value of the ord parameter.

    • np.linalg.norm() 用于求范数
    • linalg : linear(线性) + algebra(代数)
    • norm表示范数
    np.linalg.norm(x, ord=None, axis=None, keepdims=False)
    
    • 1

    Param

    • x : 表示矩阵(一维数据也是可以的~)
    • ord : 表示范数类型
      在这里插入图片描述

    x

    • num
    • matrix
    • tensor

    ord

    • ord=1:表示求列和的最大值
    • ord=2:|λE-ATA|=0,求特征值,然后求最大特征值得算术平方根
    • ord=∞:表示求行和的最大值
    • ord=None:表示求整体的矩阵元素平方和,再开根号

    axis

    ![在这里插入图片描述](https://img-blog.csdnimg.cn/e7e55088a74643f9bf5105c5b08b9589.png

    keepdims

    表示是否保持矩阵的二位特性

    • 默认为False
    • True : 保持
    • False : 不保持

    np.clip()

    Clip (limit) the values in an array.

    numpy.clip(a, a_min, a_max, out=None)
    
    
    • 1
    • 2

    Param

    • a : 输入的数组
    • a_min: 限定的最小值 也可以是数组 如果为数组时 shape必须和a一样
    • a_max:限定的最大值 也可以是数组 shape和a一样
    • out:剪裁后的数组存入的数组

    if a [ ] < a_min ----> a_min
    if a [ ] > a_max----->a_max
    between [a_min, a_max] ------> a [ ]

    For example

    >>> a = np.arange(10) # 0 1 2 3 4 5 6 7 8 9
    >>> np.clip(a, 1, 8)
    array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8]) # a被限制在1-8之间
    >>> a
    array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) # 没改变a的原值
    
    >>> np.clip(a, 3, 6, out=a) # 修剪后的数组存入到a中
    array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
    
    >>> a = np.arange(10)
    >>> a
    array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
    >>> np.clip(a, [3,4,1,1,1,4,4,4,4,4], 8)
    # 当a_min为数组时, a中每个元素和都和a_min中对应元素比较
    # 0 < 3 -->小于最小值 则等于3
    # 3 > 2 -->大于最小值 则等于本身 再和最大值比 没超过最大值 所以为3
    array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    numpy.arange()

    Return evenly spaced values within a given interval

    numpy.arange([start, ]stop, [step, ]dtype=None, *, like=None)
    
    • 1

    Param

    • arange(stop) : Values are generated within the half-open interval [0, stop) (in other words, the interval including start but excluding stop).
    • arange(start, stop) : Values are generated within the half-open interval [start, stop).
    • arange(start, stop, step) : Values are generated within the half-open interval [start, stop), with spacing between values given by step.

    在这里插入图片描述

    numpy.arccos()

    The inverse of cos
    在这里插入图片描述

    numpy.arccos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'arccos'>
    
    
    • 1
    • 2

    Param

    在这里插入图片描述

    Return在这里插入图片描述

    For example

    import numpy as np
    print('数组的反余弦值:{}'.format(np.arccos([1, -1])))
    
    • 1
    • 2

    在这里插入图片描述

    import matplotlib.pyplot as plt
    x = np.linspace(-1, 1, num=100)
    plt.plot(x, np.arccos(x), c='b')
    plt.axis('tight')
    plt.show()
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述

  • 相关阅读:
    Linux安装DataHub (开源元数据管理工具)
    rust学习——操作字符串、字符串转义、操作UTF8-字符串 (操作中文字符串)
    mysql图书管理系统(49-56)源代码
    【Java面试】Mysql为什么使用B+Tree作为索引结构
    2023 Shandong Provincial Collegiate Programming Contest
    Unity 将是驱动 C# 增长的引擎吗 ?
    生成式预训练语言模型能否视作闭卷问答的知识库?
    Python技巧---tqdm库的使用
    odoo16前端框架分析1 boot.js
    Centos搭建k8s集群
  • 原文地址:https://blog.csdn.net/weixin_45646640/article/details/133749249