File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 7
7
from torch .utils .data import DataLoader
8
8
from torchvision import transforms
9
9
from torchvision import datasets
10
-
10
+ import time
11
11
# 定义超参数
12
12
batch_size = 32
13
13
learning_rate = 1e-3
@@ -45,8 +45,9 @@ def forward(self, x):
45
45
46
46
# 开始训练
47
47
for epoch in range (num_epoches ):
48
- print ('epoch {}' .format (epoch + 1 ))
49
48
print ('*' * 10 )
49
+ print ('epoch {}' .format (epoch + 1 ))
50
+ since = time .time ()
50
51
running_loss = 0.0
51
52
running_acc = 0.0
52
53
for i , data in enumerate (train_loader , 1 ):
@@ -97,6 +98,7 @@ def forward(self, x):
97
98
eval_acc += num_correct .data [0 ]
98
99
print ('Test Loss: {:.6f}, Acc: {:.6f}' .format (eval_loss / (len (
99
100
test_dataset )), eval_acc / (len (test_dataset ))))
101
+ print ('Time:{:.1f} s' .format (time .time () - since ))
100
102
print ()
101
103
102
104
# 保存模型
You can’t perform that action at this time.
0 commit comments