Open ggampu opened 6 years ago
Q: Why we have to use delta for log function in cross_entropy_loss class?
A: The minimum value of the data type 'float' is 1.175494351 E – 38. If the exp(s) value is smaller than it, exp(s) become zero. You can simply test this code which returns zero.
a = np.float32(np.exp(-104))
This can be happened by first initialization, improper normalization, and higher learning rate. Note that the default data type of deep learning wrapper is float32.
하나만 더 질문하겠습니다. cross-entropy 구현할 때, -ylog(x)-(1-y)log(1-x) 와 -y*log(x) 중에 후자를 사용하면 되는건가요? 수업시간에는 loss functioin 을 log(softmax) 로 한꺼번에 계산한 것으로 배웠던것 같은데, 그걸 cross entropy 에 적용해서 분리해서 코딩해야 하면 위에 언급한 두개중에 후자로 해야 수업시간에 배운 값이 나오는것 같습니다. 후자로 사용하면 되나요?
앞의 식은 binary classification에 대한 cross entropy입니다. 뒤의 식으로 하는게 맞습니다.
안녕하세요
cross_entropy_loss 구현할때, 로그에 0이 들어가지 않도록 델타를 사용하라고 하였는데, cross_entropy_loss 구현시에 softmax function 을 사용하면 exponential 때문에 softmax 함수값이 절대 0이 될수 없지 않나요? 왜 0이 들어가는것을 고려해야 하는지요?