![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
numpy 基础
执笔论英雄
这个作者很懒,什么都没留下…
展开
-
numpy_1
import numpy world_alcohol = numpy.genfromtxt("world_alcohol.txt", delimiter=",") print(type(world_alcohol)) print(world_alcohol) <class 'numpy.ndarray'> [[ nan nan nan ...原创 2019-01-30 12:46:44 · 196 阅读 · 0 评论 -
numpy_2
import numpy #it will compare the second value to each element in the vector # If the values are equal, the Python interpreter returns True; otherwise, it returns False vector = numpy.array([5, 10, 15...原创 2019-01-30 13:24:01 · 128 阅读 · 0 评论 -
NUMPY_3
import numpy as np a = np.arange(15).reshape(3, 5) a array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) a.shape (3, 5) #the number of axes (dimensions) of the ...原创 2019-01-30 13:49:50 · 78 阅读 · 0 评论 -
numpy_4
import numpy as np B = np.arange(3) print(B) #print np.exp(B) print (np.sqrt(B)) [0 1 2] [0. 1. 1.41421356] #Return the floor of the input a = np.floor(10*np.random.random((3,4))) pr...原创 2019-01-30 14:14:06 · 103 阅读 · 0 评论 -
numpy_5
import numpy as np data = np.sin(np.arange(20)).reshape(5,4) print (data) print(10*"*") ind = data.argmax(axis=0) print (ind) print(10*"*") print(range(0,4)) print(10*"*") data_max = data[ind, range(d...原创 2019-01-30 14:37:33 · 98 阅读 · 0 评论 -
numpy_6
import numpy as np #1:8*8棋盘矩阵,其中1、3、5、7行&&0、2、4、6列的元素置为1 1 ,3,5,7列&&0,2,4,6行也是1 z = np.zeros((8,8),dtype=int) z[1::2,::2] = 1 z[::2,1::2] = 1 print(z) [[0 1 0 1 0 1 0 1] [1 0 1 0 ...原创 2019-01-30 14:44:31 · 706 阅读 · 0 评论 -
numpy_7
import numpy as np #交换矩阵的其中两行 a = np.arange(25).reshape(5,5) print (a) a[[0,1]] = a[[1,0]] print (a) [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19] [20 21 22 23 24]] [[ 5 6...原创 2019-01-30 15:00:11 · 235 阅读 · 0 评论 -
np.stack()用法
import tensorflow as tf import numpy as np def sobel_filter(): fx = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]).astype(np.float32) fy = np.array([[-1, -2, -1], [0, 0, 0], [1, 2, 1]]).astype...原创 2019-03-11 20:53:08 · 326 阅读 · 0 评论