We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# Cost 계산 (1) hypothesis = F.softmax(x_train.matmul(W) + b, dim=1) # or .mm or @ y_one_hot = torch.zeros_like(hypothesis) y_one_hot.scatter_(1, y_train.unsqueeze(1), 1) cost = (y_one_hot * -torch.log(F.softmax(hypothesis, dim=1))).sum(dim=1).mean() # cost로 H(x) 개선 optimizer.zero_grad() cost.backward() optimizer.step() # 100번마다 로그 출력 if epoch % 100 == 0: print('Epoch {:4d}/{} Cost: {:.6f}'.format( epoch, nb_epochs, cost.item() ))
위와 같이 16번째 쉘의 cost 함수를 계산하는 부분에 softmax가 2번 들어간 것으로 확인됩니다. 물론 2번 넣어도 계산이 잘 되겠지만, 의도하신건지 궁금합니다.
감사합니다.
The text was updated successfully, but these errors were encountered:
제 생각에는 오타같아 보입니다.
두번째 softmax() 를 빼고 계산하여도 같은 결과 값이 나옵니다. 이미 softmax()를 통해 0 ~1 사이의 분포로 바꾸었는데 그걸 다시 softmax() 해도 같은 값만 나옵니다.
softmax()
그리고 슬라이드 설명에서는 cost = (y_one_hot * -torch.log(hypothesis)).sum(dim=1).mean()으로 적혀 있습니다.
cost = (y_one_hot * -torch.log(hypothesis)).sum(dim=1).mean()
해당 문서를 수정하는게 좋을 것 같네요. @kh-kim
Sorry, something went wrong.
No branches or pull requests
위와 같이 16번째 쉘의 cost 함수를 계산하는 부분에 softmax가 2번 들어간 것으로 확인됩니다.
물론 2번 넣어도 계산이 잘 되겠지만, 의도하신건지 궁금합니다.
감사합니다.
The text was updated successfully, but these errors were encountered: