numpy的使用

使用 %timeit 魔数 命令 计算耗时
np.mean(lst) -> 计算 lst 的平均数
np.average(x,weight=w) 安装 权重计算平均值

numpy 两个 数组直接 乘 就是 矩阵乘法了
np.sum(x*w)/np.sum(w) 按照 权重 求平均值

ar = np.arange(6) 求数组的维度
ar.ndim —> 数组的维度
ar.size —> 数组的数据个数
ar.shape --> (行,列)
ar.itemsize --> 每一个元素的占据空间数
np.ones() --> 全 1 数组
np.ones_like(b) 维度和 b相同的全1 数组
np.eye() 单位矩阵
np.linspace(1,2,step) 1,到 2 的 均匀分布数组

相关文章:

  • 2022-01-05
  • 2021-12-11
  • 2022-02-17
  • 2022-01-08
  • 2021-12-07
  • 2021-08-26
  • 2022-12-23
猜你喜欢
  • 2021-09-14
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2022-01-05
  • 2021-10-02
  • 2021-07-27
相关资源
相似解决方案