인프런 커뮤니티 질문&답변
5-1 CNN코드에서 모델 정확도 구할때
작성
·
338
·
수정됨
1
안녕하세요! 좋은 강의 감사드립니다.
5-1 CNN코드에서 모델 정확도 구할 때
correct = 0
total = 0
with torch.no_grad():
for data in testloader:
images, labels = data[0].to(device), data[1].to(device)
outputs = net(images)
_, predicted = torch.max(outputs.data, 1)
total += labels.size(0) # 개수 누적(총 개수)
correct += (predicted == labels).sum().item() # 누적(맞으면 1, 틀리면 0으로 합산)
print('Accuracy of the network on the 10000 test images: %d %%' % (100 * correct / total))
_, predicted = torch.max(outputs.data, 1)에서 _ 는 무엇을 뜻하나요?? 그리고 max에서 max(outputs.data, 1) 에서 1은 무엇을 의미하나요??
감사합니다!!




