zoukankan      html  css  js  c++  java
  • numpy常用函数

    查看属性

    .ndim :维度

    .shape :各维度的尺度 (2,5)

    .size :元素的个数 10

    .dtype :元素的类型 dtype(‘int32’)

    ndarray数组的创建

    np.arange(n) ; 元素从0到n-1的ndarray类型

    np.ones(shape): 生成全1

    np.zeros((shape), ddtype = np.int32) : 生成int32型的全0

    np.full(shape, val): 生成全为val

    np.eye(n) : 生成单位矩阵

    np.linspace(1,10,4): 根据起止数据等间距地生成数组

    np.linspace(1,10,4, endpoint = False):endpoint 表示10是否作为生成的元素

    数组的维度变换

    .reshape(shape) : 不改变当前数组,依shape生成

    .resize(shape) : 改变当前数组,依shape生成

    .flatten() : 对数组进行降维,返回折叠后的一位数组

    矩阵操作

    np.square(a): 计算各元素的平方

    np.int64(a): 将a的值转换成整数,例子,relu的求导:np.int64(A2 > 0)

    np.argmax(input,axis): 根据axis取值的不同返回每行或者每列最大值的索引


    待续.................

  • 相关阅读:
    第 4 章 容器
    第 4 章 容器
    第 4 章 容器
    第 4 章 容器
    第 3 章 镜像
    第 3 章 镜像
    seekbar拖动条控件
    OnClick,onLongClick,OnTouch调用机制
    在TextView文本中实现activity跳转
    TextView显示html图片方法
  • 原文地址:https://www.cnblogs.com/douzujun/p/13081518.html
Copyright © 2011-2022 走看看