-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalysis.py
174 lines (136 loc) · 5.38 KB
/
analysis.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#%%
import utils
import copy
import pandas as pd
import os
import shutil
import numpy as np
import progressbar as pbar
import sys
import time
import logging
import pathlib
import re
from PIL import Image
import matplotlib.pyplot as plt
def filter_data(l,a= 0.2):
lc = l.copy()
for i in range(1,len(l)):
lc[i] = lc[i]*a + lc[i-1]*(1-a)
return lc
#%%
#对比验证集损失函
fig,ax = plt.subplots()
data = utils.transform_log_to_pd_dataframe("./logs/traffic_LeNet_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = 'LeNet')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_Alexnet_coslr_64x64_16_0.005.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = 'AlexNet')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_ResNet18_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = 'ResNet18')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_VGG11_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = 'VGG11')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_DesenNet_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = 'DesenNet')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_EfficientNetb0_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = 'EfficientNetb0')
ax.legend()
ax.set_xlabel("epoch")
ax.set_ylim(0, 8)
ax.set_ylabel("val_loss")
ax.set_title("epoch/val_loss")
plt.pause(0.1)
#%%
#对比验证集准确率
fig,ax = plt.subplots()
data = utils.transform_log_to_pd_dataframe("./logs/traffic_LeNet_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = 'LeNet')
max_acc = data.val_acc.max()
print('LeNet:',max_acc)
data = utils.transform_log_to_pd_dataframe("./logs/traffic_Alexnet_coslr_64x64_16_0.005.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = 'AlexNet')
max_acc = data.val_acc.max()
print('AlexNet:',max_acc)
data = utils.transform_log_to_pd_dataframe("./logs/traffic_ResNet18_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = 'ResNet18')
max_acc = data.val_acc.max()
print('ResNet18:',max_acc)
data = utils.transform_log_to_pd_dataframe("./logs/traffic_VGG11_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = 'VGG11')
max_acc = data.val_acc.max()
print('VGG11:',max_acc)
data = utils.transform_log_to_pd_dataframe("./logs/traffic_DesenNet_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = 'DesenNet')
max_acc = data.val_acc.max()
print('DesenNet:',max_acc)
data = utils.transform_log_to_pd_dataframe("./logs/traffic_EfficientNetb0_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = 'EfficientNetb0')
max_acc = data.val_acc.max()
print('EfficientNetb0:',max_acc)
ax.legend()
ax.set_xlabel("epoch")
ax.set_ylim(70, 100)
ax.set_ylabel("val_acc")
ax.set_title("epoch/val_acc")
plt.pause(0.1)
#%%
#学习率变化图
fig,ax = plt.subplots()
data = utils.transform_log_to_pd_dataframe("./logs/traffic_EfficientNetb0_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,data.lr.values)
ax.legend()
ax.set_xlabel("epoch")
ax.set_ylabel("learn rate")
ax.set_title("epoch/lr")
plt.pause(0.1)
#%%
# batch size 大小影响
fig,ax = plt.subplots()
data = utils.transform_log_to_pd_dataframe("./logs/traffic_ResNet18_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,data.val_loss.values,label = 'batch = 16')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_ResNet18_coslr_64x64_64_0.01.log")
ax.plot(data.epoch.values,data.val_loss.values,label = 'batch = 64')
ax.legend()
ax.set_xlabel("epoch")
ax.set_ylim(0, 8)
ax.set_ylabel("val_loss")
ax.set_title("ResNet18 epoch/val_loss")
plt.pause(0.1)
#%%
# batch size 大小影响
fig,ax = plt.subplots()
data = utils.transform_log_to_pd_dataframe("./logs/traffic_ResNet18_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,data.val_acc.values,label = 'batch = 16')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_ResNet18_coslr_64x64_64_0.01.log")
ax.plot(data.epoch.values,data.val_acc.values,label = 'batch = 64')
ax.legend()
ax.set_xlabel("epoch")
ax.set_ylim(70, 100)
ax.set_ylabel("val_acc")
ax.set_title("ResNet18 epoch/val_acc")
plt.pause(0.1)
#%%
# 图像尺寸影响
fig,ax = plt.subplots()
data = utils.transform_log_to_pd_dataframe("./logs/traffic_LeNet_224x224_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = '224x224')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_LeNet_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_loss.values),label = '64x64')
ax.legend()
ax.set_xlabel("epoch")
ax.set_ylim(0, 8)
ax.set_ylabel("val_loss")
ax.set_title("LeNet epoch/val_loss")
plt.pause(0.1)
fig,ax = plt.subplots()
data = utils.transform_log_to_pd_dataframe("./logs/traffic_LeNet_224x224_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = '224x224')
data = utils.transform_log_to_pd_dataframe("./logs/traffic_LeNet_coslr_64x64_16_0.01.log")
ax.plot(data.epoch.values,filter_data(data.val_acc.values),label = '64x64')
ax.legend()
ax.set_xlabel("epoch")
ax.set_ylim(70, 100)
ax.set_ylabel("val_acc")
ax.set_title("LeNet epoch/val_acc")
plt.pause(0.1)
#%%
plt.show()