Skip to content

Commit 647760f

Browse files
committed
update logistic regression
1 parent 3ce09b1 commit 647760f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

02-Logistic Regression/Logistic_Regression.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from torch.utils.data import DataLoader
88
from torchvision import transforms
99
from torchvision import datasets
10-
10+
import time
1111
# 定义超参数
1212
batch_size = 32
1313
learning_rate = 1e-3
@@ -45,8 +45,9 @@ def forward(self, x):
4545

4646
# 开始训练
4747
for epoch in range(num_epoches):
48-
print('epoch {}'.format(epoch + 1))
4948
print('*' * 10)
49+
print('epoch {}'.format(epoch + 1))
50+
since = time.time()
5051
running_loss = 0.0
5152
running_acc = 0.0
5253
for i, data in enumerate(train_loader, 1):
@@ -97,6 +98,7 @@ def forward(self, x):
9798
eval_acc += num_correct.data[0]
9899
print('Test Loss: {:.6f}, Acc: {:.6f}'.format(eval_loss / (len(
99100
test_dataset)), eval_acc / (len(test_dataset))))
101+
print('Time:{:.1f} s'.format(time.time() - since))
100102
print()
101103

102104
# 保存模型

0 commit comments

Comments
 (0)