zoukankan      html  css  js  c++  java
  • numpy学习(一)

    (一)基础学习

    学习渠道:阿里天池AI学习——Numpy基础(传送门

    (二)练习篇

    练习渠道:Numpy基础100题(Part 1)

    1. Import the numpy package under the name np(★☆☆)

    1 import numpy as np 

    2. Print the numpy version and the configuration(★☆☆)

    1 print(np.version)
    2 np.show_config()

    3. Create a null vector of size 10(★☆☆)

    1 arr = np.zeros(10)
    2 print(arr)

    运行结果:[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]

    4. How to find the memory size of any array (★☆☆)

    1 print("%d bytes" %(arr.size*arr.itemsize))

    运行结果:80 bytes

    5. How to get the documentation of the numpy add function from the command line? (★☆☆)

    np.add?

    6. Create a null vector of size 10 but the fifth value which is 1 (★☆☆)

    1 arr = np.zeros(10)
    2 arr[4] = 1;
    3 print(arr)

    运行结果:[0. 0. 0. 0. 1. 0. 0. 0. 0. 0.]

    7. Create a vector with values ranging from 10 to 49 (★☆☆)

    1 arr = np.arange(10,50)
    2 print(arr)

    运行结果:[10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49]

    8. Reverse a vector (first element becomes last) (★☆☆)

    1 arr = np.arange(10,50)
    2 print(arr[::-1])

    运行结果:[49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10]

    9. Create a 3x3 matrix with values ranging from 0 to 8 (★☆☆)

    1 arr = np.arange(9).reshape(3,3)
    2 print(arr)

    运行结果:[[0 1 2] [3 4 5] [6 7 8]]

    10. Find indices of non-zero elements from [1,2,0,0,4,0] (★☆☆)

    1 arr = np.array([1,2,0,0,4,0])
    2 print(arr.nonzero()[0])

    运行结果:[0 1 4]

  • 相关阅读:
    网络设备操作命令
    "Realtek PCIe GBE Family Controller"网卡抓带Vlan Tag的包
    ubuntu16.04 samba 配置
    readelf -s 命令‘symbol’名字显示不全
    APUE Unix环境高级编程读书笔记
    Jmeter之文件上传
    百度去广告chrome插件
    zookeeper的安装与使用
    spring中bean获取工具
    关于maven的一些记录
  • 原文地址:https://www.cnblogs.com/orangecyh/p/11574551.html
Copyright © 2011-2022 走看看