-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathplot.py
59 lines (45 loc) · 4.79 KB
/
plot.py
1
2
3
4
5
6
7
8
9
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
50
51
52
53
54
55
56
57
58
59
import numpy as np
import matplotlib.pyplot as plt
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 16,
}
# 生成随机数据
x = np.arange(0, 10, 0.1)
y = np.sin(x)
std = np.random.uniform(0.05, 0.15, len(x))
mean = y + np.random.normal(0, std)
x = np.arange(0, 22)
tiny_mean = np.array([1.2186670303344727, 1.0018041133880615, 0.9951106309890747, 1.0047252178192139, 1.4839993715286255, 1.654506802558899, 0.9895612597465515, 1.2118194103240967, 1.2168138027191162, 1.6429681777954102])
tiny_std = np.array([0.4020204544067383, 0.007127926219254732, 0.015775736421346664, 0.018679386004805565, 0.33479368686676025, 0.29026249051094055, 0.007766170427203178, 0.24259251356124878, 0.318845272064209, 0.3086416721343994])
small_mean = np.array([1.2777522802352905, 0.9992858171463013, 0.9924950003623962, 0.9974894523620605, 1.2518179416656494, 1.4359736442565918, 1.5817147493362427, 0.9829406142234802, 1.224649429321289, 0.9872152209281921, 1.4860173463821411, 1.5040074586868286, 1.114086627960205, 0.9861724972724915, 1.280491828918457, 1.4338750839233398, 1.3995933532714844, 1.487770676612854, 1.4466452598571777, 1.5566579103469849, 1.4329417943954468, 1.399132251739502])
small_std = np.array([0.3707650899887085, 0.005320016760379076, 0.01742757111787796, 0.010709324851632118, 0.3287031650543213, 0.3348124921321869, 0.27193593978881836, 0.010663282126188278, 0.261054664850235, 0.012790788896381855, 0.3246471881866455, 0.30791446566581726, 0.17148521542549133, 0.008789893239736557, 0.24888676404953003, 0.23784777522087097, 0.20222364366054535, 0.20966853201389313, 0.2758185863494873, 0.36627525091171265, 0.3615717589855194, 0.4627654254436493])
base_mean = np.array([1.2550468444824219, 0.995892345905304, 0.9991623759269714, 0.9978345632553101, 1.315889835357666, 1.5147002935409546, 1.4340146780014038, 1.2214144468307495, 0.9811185598373413, 1.3131279945373535, 1.4564008712768555, 1.4946566820144653, 1.483350396156311, 1.3541505336761475, 1.3524962663650513, 0.9466572999954224, 0.918433427810669, 0.9821075797080994, 1.0968248844146729, 1.028059482574463, 1.053618311882019, 0.9481956958770752])
base_std = np.array([0.3546122908592224, 0.009672180749475956, 0.020335257053375244, 0.01807529106736183, 0.3377276062965393, 0.3055002987384796, 0.2837183475494385, 0.2826721668243408, 0.010324746370315552, 0.2860591411590576, 0.3134777545928955, 0.2585407495498657, 0.19257256388664246, 0.1745527982711792, 0.22277310490608215, 0.08952218294143677, 0.09958166629076004, 0.25621435046195984, 0.34584882855415344, 0.38283559679985046, 0.5019219517707825, 0.5248185992240906])
# 创建图形对象
ax = plt.subplot(211)
# 画出均值散点
ax.plot(np.arange(0, 10), tiny_mean, color='r', label='Tiny', linewidth=2)
ax.fill_between(np.arange(0, 10), tiny_mean-tiny_std, tiny_mean+tiny_std, color='r', alpha=0.2, )
ax.plot(x, small_mean, color='royalblue', label='Small', linewidth=2)
ax.fill_between(x, small_mean-small_std, small_mean+small_std, color='royalblue', alpha=0.2, )
ax.plot(x, base_mean, color='gold', label='Base', linewidth=2)
# 绘制标准差阴影区域
ax.fill_between(x, base_mean-base_std, base_mean+base_std, alpha=0.2, color='gold', )
# 添加图例和标签
ax.legend(loc=3, prop=font1)
ax.set_xlabel('Layer', fontsize=18)
ax.set_ylabel('Mean scaling ratio', fontsize=18)
# ax.set_title('Mean and Standard Deviation', fontsize=22)
tiny_max = np.array([2.281484603881836, 1.045531153678894, 1.0930722951889038, 1.1950817108154297, 2.094877243041992, 2.1013803482055664, 1.0239717960357666, 1.925851821899414, 2.0892221927642822, 2.1233768463134766])
small_max = np.array([2.315664768218994, 1.0202850103378296, 1.1118519306182861, 1.135292887687683, 2.052560806274414, 2.082548141479492, 2.078901529312134, 1.0125365257263184, 2.0334889888763428, 1.0684832334518433, 2.0785574913024902, 2.082737684249878, 1.770531415939331, 1.0346879959106445, 2.0871753692626953, 2.1432695388793945, 1.9439804553985596, 2.0503478050231934, 2.034951686859131, 2.035959005355835, 2.0690555572509766, 2.0882840156555176])
base_max = np.array([2.3754663467407227, 1.0397008657455444, 1.106102705001831, 1.0992555618286133, 2.0906083583831787, 2.146918773651123, 2.1020162105560303, 1.9786731004714966, 1.0457018613815308, 2.0612034797668457, 2.046666145324707, 2.0550289154052734, 2.030028820037842, 1.9046847820281982, 2.0553436279296875, 1.0086308717727661, 1.0497912168502808, 1.6935245990753174, 1.959445595741272, 1.8739820718765259, 1.9834498167037964, 1.9190270900726318])
ax = plt.subplot(212)
ax.plot(np.arange(0, 10), tiny_max, color='r', label='Tiny', linewidth=2)
ax.plot(x, small_max, color='royalblue', label='Small', linewidth=2)
ax.plot(x, base_max, color='gold', label='Base', linewidth=2)
ax.legend(loc=3, prop=font1)
ax.set_xlabel('Layer', fontsize=18)
ax.set_ylabel('Max scaling ratio', fontsize=18)
# 显示图形
plt.show()