Skip to content

Commit 717dabb

Browse files
committed
加入说明
1 parent 3cc5733 commit 717dabb

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

CNNModel_EarlyStopping_Save_Restore/CNNModel_EarlyStopping_Save_Restore.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def cls_accuracy(correct):
170170
def validation_accuracy():
171171
correct, _ = predict_cls_validation()
172172
return cls_accuracy(correct)
173-
'''define a function to'''
173+
'''define a function to calculate test acc'''
174174
def print_test_accuracy(show_example_errors=False,
175175
show_confusion_matrix=False):
176176
correct, cls_pred = predict_cls_test()
@@ -204,14 +204,14 @@ def plot_conv_weights(weights, input_channel=0):
204204
ax.set_xticks([])
205205
ax.set_yticks([])
206206
plt.show()
207-
#print_test_accuracy()
208-
#plot_conv_weights(weights=weights_conv1)
209-
#optimize(10000)
210-
#print_test_accuracy(show_example_errors=True,
211-
#show_confusion_matrix=True)
212-
#plot_conv_weights(weights=weights_conv1)
213-
'''restore the variables that saved on disk'''
214-
saver.restore(sess=session, save_path=save_path)
215-
print_test_accuracy(True, True)
207+
print_test_accuracy()
208+
plot_conv_weights(weights=weights_conv1)
209+
optimize(10000)
210+
print_test_accuracy(show_example_errors=True,
211+
show_confusion_matrix=True)
212+
plot_conv_weights(weights=weights_conv1)
213+
#'''restore the variables that saved on disk'''
214+
#saver.restore(sess=session, save_path=save_path)
215+
#print_test_accuracy(True, True)
216216

217217

Binary file not shown.
Binary file not shown.

readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,30 @@ def optimize(num_iterations):
13451345
time_diff = end_time-start_time
13461346
print("Time usage:" + str(timedelta(seconds=int(round(time_diff)))))
13471347
```
1348+
- 调用`optimize(10000)`输出信息
1349+
1350+
``` stylus
1351+
Iter: 5100, Train_batch accuracy:100.0%, validation acc: 98.8% *
1352+
Iter: 5200, Train_batch accuracy:100.0%, validation acc: 98.3%
1353+
Iter: 5300, Train_batch accuracy:100.0%, validation acc: 98.7%
1354+
Iter: 5400, Train_batch accuracy: 98.4%, validation acc: 98.6%
1355+
Iter: 5500, Train_batch accuracy: 98.4%, validation acc: 98.6%
1356+
Iter: 5600, Train_batch accuracy:100.0%, validation acc: 98.7%
1357+
Iter: 5700, Train_batch accuracy: 96.9%, validation acc: 98.9% *
1358+
Iter: 5800, Train_batch accuracy:100.0%, validation acc: 98.6%
1359+
Iter: 5900, Train_batch accuracy:100.0%, validation acc: 98.6%
1360+
Iter: 6000, Train_batch accuracy: 98.4%, validation acc: 98.7%
1361+
Iter: 6100, Train_batch accuracy:100.0%, validation acc: 98.7%
1362+
Iter: 6200, Train_batch accuracy:100.0%, validation acc: 98.7%
1363+
Iter: 6300, Train_batch accuracy: 98.4%, validation acc: 98.8%
1364+
Iter: 6400, Train_batch accuracy: 98.4%, validation acc: 98.8%
1365+
Iter: 6500, Train_batch accuracy:100.0%, validation acc: 98.7%
1366+
Iter: 6600, Train_batch accuracy:100.0%, validation acc: 98.7%
1367+
Iter: 6700, Train_batch accuracy:100.0%, validation acc: 98.8%
1368+
No improvement found in a while, stop running
1369+
Time usage:0:18:43
1370+
```
1371+
可以看到最后10次输出(没100次输出一次)在验证集上准确度都没有提高,直接保存
13481372

13491373
### 3、 小批量预测并计算准确率
13501374
- 因为需要预测**测试集和验证集**,这里参数指定需要的images

0 commit comments

Comments
 (0)