Commit c5ff8825 by yuxguo

fix

parent 5f1dd634
......@@ -421,7 +421,7 @@ def validate(validloader, model, epoch):
accuracy = correct * 100. / label.size()[0]
acc_all += accuracy
if counter > 0:
logging.info("Total Validation Acc: {:.4f}".format(acc_all/float(counter)))
logging.info("Total Validation Acc at epoch {}: {:.4f}".format(epoch, acc_all/float(counter)))
return acc_all/float(counter)
def test(testloader, model, epoch):
......@@ -447,7 +447,7 @@ def test(testloader, model, epoch):
accuracy = correct * 100. / label.size()[0]
acc_all += accuracy
if counter > 0:
logging.info("Total Testing Acc: {:.4f}".format(acc_all / float(counter)))
logging.info("Total Testing Acc at epoch {}: {:.4f}".format(epoch, acc_all / float(counter)))
return acc_all/float(counter)
def main():
......@@ -466,8 +466,9 @@ def main():
for epoch in range(args.epochs):
train(trainloader, optimizer, model, epoch)
validate(validloader, model, epoch)
test(testloader, model, epoch)
if epoch % 5 == 0:
validate(validloader, model, epoch)
test(testloader, model, epoch)
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment