• 数组操作符


    1 print(x + y) # elementwise addition     [1 2 3] + [4 5 6] = [5  7  9]
    2 print(x - y) # elementwise subtraction  [1 2 3] - [4 5 6] = [-3 -3 -3]
    [5 7 9]
    [-3 -3 -3]

    1 print(x * y) # elementwise multiplication  [1 2 3] * [4 5 6] = [4  10  18]
    2 print(x / y) # elementwise divison         [1 2 3] / [4 5 6] = [0.25  0.4  0.5]
    [ 4 10 18]
    [ 0.25  0.4   0.5 ]

    1 print(x**2) # elementwise power  [1 2 3] ^2 =  [1 4 9]
    [1 4 9]

    1 x.dot(y) # dot product  1*4 + 2*5 + 3*6
    32

    1 z = np.array([y, y**2])
    2 print(len(z)) # number of rows of array
    2

    1 z = np.array([y, y**2])
    2 z
    array([[ 4,  5,  6],
           [16, 25, 36]])

    1 z.shape
    (2, 3)

    1 z.T
    array([[ 4, 16],
           [ 5, 25],
           [ 6, 36]])

    1 z.T.shape
    (3, 2)

    1 z.dtype
    dtype('int64')

    1 z = z.astype('f')
    2 z.dtype
    dtype('float32')





  • 相关阅读:
    jQuery中的事件
    Ajax跨域
    javascript的时间委托
    大型数据库优化技巧
    mysql数据库忘记密码时如何修改
    DAY69-nosql
    DAY68-redis
    DAY67-Memcached
    DAY65-apache的安装
    DAY63-centos介绍
  • 原文地址:https://www.cnblogs.com/zhengzhe/p/8511067.html
Copyright © 2020-2023  润新知