深度学习之numpy学习笔记

  • numpy.zeros(shape, dtype=float, order='c')创建指定大小的数组,数组元素以 0 来填充
  • numpy.ones()    创建一个全是1的数组
  • numpy.empty()    创建一个内容随机并且依赖于内存状态的数组

    #如不指定类型,默认创建的数组类型为float64

 

  • numpy.random.permutation(x)  x为序列或整数,当x为整数时,返回随机排列range(x);当x为序列时,返回x随机排列的序列
  • numpy.array(object, dtype=None, copy=True, order='K', subok=False, ndmin=0)  将对象转换为数组
  • tolist() 将数组转换为列表
  • arange([start, ]stop, [step, ]dtype=None) 返回的是array类型 默认从零开始,步长为1
  • numpy.linspce(start, stop, num=50, endpoint=True, retstep=False, dtype=None)  返回固定个数的步长相同的数据

 

  • 矩阵的乘法运算符*是按元素位置计算,矩阵乘法可以使用dot函数实现

 

  • numpy.fromfunction(function, shape, *, dtype=<class 'float'>, **kwargs)

  • functioncallable

    The function is called with N parameters, where N is the rank of shape. Each parameter represents the coordinates of the array varying along a specific axis. For example, if shape were (2, 2), then the parameters would be array([[0, 0], [1, 1]]) and array([[0, 1], [0, 1]])

[In]:def fun(x, y):
        return x * 2 + y
​
     b = np.fromfunction(fun,(2, 3),dtype=int)

[In]:b
[Out]:array([[0, 1, 2],
           [2, 3, 4]])

 

  • 组合拆分数组
  • numpy.vstack() 使多个数组沿第一个轴组合
  • numpy.hstack()                 沿第二个轴组合
  • numpy.column_stack() 将多个一维数组按对应位置组合成新的二维数组
  • numpy.vsplit()  将数组沿纵轴分割
  • numpy.hsplit()  将数组沿水平轴分割

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值