标签:numpy for and poi put strip 自己 print span
给自己新挖个坑:开始刷cs231n深度学习。
看了一下导言的pdf,差缺补漏。
s = "hello" print s.capitalize() # 首字母大写; prints "Hello" print s.upper() # 全部大写; prints "HELLO" print s.rjust(7) #空格; prints " hello" print s.center(7) # 居中; prints " hello " print s.replace(‘l‘, ‘(ell)‘) # 替换; # prints "he(ell)(ell)o" print ‘ world ‘.strip() # Strip leading and trailing whitespace; prints "world"
切片和索引
nums = range(5) # 生成[0,1,2,3,4] print nums print nums[:] # 全部输出; prints "[0, 1, 2, 3, 4]" print nums[:-1] # 倒数第一个直接用-1; prints "[0, 1, 2, 3]"
元组
d = {(x, x + 1): x for x in range(10)} #创建元组型字典 t = (5, 6) # 创建元组 print type(t) # Prints "<type ‘tuple‘>" print d[t] # Prints "5" print d[(1, 2)] # Prints "1"
创建空array
v = np.array([1, 0, 1]) y = np.empty_like(v) # [0,0,0]
v = np.array([1, 0, 1])
vv = np.tile(v, (4, 1)) # [1,0,1]
[1,0,1]
[1,0,1]
[1,0,1]
矩阵转置
a = np.array([[1,2,3],[4,5,6]])
b = a.T#输出a的转置
plt
import numpy as np import matplotlib.pyplot as plt x = np.arange(0, 3 * np.pi, 0.1) y = np.sin(x) plt.plot(x, y) plt.show()
subplot
import numpy as np import matplotlib.pyplot as plt # Compute the x and y coordinates for points on sine and cosine curves x = np.arange(0, 3 * np.pi, 0.1) y_sin = np.sin(x) y_cos = np.cos(x) plt.subplot(2, 1, 1) plt.plot(x, y_sin) plt.title(‘Sine‘) plt.subplot(2, 1, 2) plt.plot(x, y_cos) plt.title(‘Cosine‘) plt.show()
以上
:)
标签:numpy for and poi put strip 自己 print span
原文地址:http://www.cnblogs.com/deleteme/p/6885840.html