最近用于对比结果,使用到了python的基本操作,之前也有了解但是与M相比难免有些区别
txt文本数据如下
0.9453125 0.9640625 0.671875 0.55625 0.475
0.921875 0.965625 0.7828125 0.5046875 0.6421875
0.9390625 0.946875 0.9328125 0.496875 0.5390625
0.9640625 0.9671875 0.89375 0.509375 0.4890625
0.8984375 0.9640625 0.875 0.5015625 0.428125
import matplotlib.pyplot as plt
import numpy as np
winSizes = [1,5,10,20,30]; #1,5,10,20,30
learning_rates = [0.001,0.01,0.1,1,5] #0.0001,0.1,1,5
data = []
filename = './winS-lr_hideSize=5.txt'
def loadData(filename):
infile = open(filename,'r')
ret = np.zeros([5,5])
cnt = 0
for line in infile:
dataline = [float(s) for s in line.split()]
for i in range(5):
ret[cnt,i] = dataline[i]
cnt = cnt+1
return ret
ret = loadData(filename)
for i in range(5):
plt.plot(learning_rates,ret[i,:])
plt.show()
方法二:(补充2019/03/28)
with open('./highway_gps.csv', 'rb') as f:
reader = csv.reader(f)
for row in reader:
contents = row[0]
x, y, s, dx, dy = contents.split()
gps_x.append(float(x))
gps_y.append(float(y))
gps_s.append(float(s))
gps_dx.append(float(dx))
gps_dy.append(float(dy))