TensorFlow에서 로짓이라는 단어의 의미는 무엇입니까?
다음 TensorFlow 함수에서, 우리는 최종 층에서 인공 뉴런의 활성화를 공급해야합니다. 이해합니다. 그러나 왜 그것이 로짓이라고 불리는 지 이해하지 못합니까? 수학 함수가 아닌가?
loss_function = tf.nn.softmax_cross_entropy_with_logits(
logits = last_layer,
labels = target_output
)
로 짓은 많은 다른 것을 의미 할 수있는 과부하 된 용어입니다.
Math
에서
은 확률 (
[0, 1]
)을 R (
(-inf, inf)
)에 매핑하는 함수입니다.
0.5의 확률은 0의 로짓에 해당합니다. 음의로 짓은 0.5보다 작고 0.5보다 큰 확률에 해당합니다.
ML에서
, 그것은
분류 모델이 생성하는 원시 (비정규 화 된) 예측 벡터로, 보통 정규화 함수로 전달됩니다. 모형이 다중 등급 분류 문제를 해결하는 경우로 짓은 일반적으로 softmax 함수의 입력이됩니다. 그런 다음 softmax 함수는 가능한 각 클래스에 대해 하나의 값으로 (정규화 된) 확률로 구성된 벡터를 생성합니다.
로 짓은 또한 때때로
시그 모이 드 함수의 요소 별 역수를 나타냅니다.
로 짓은
확률
[0, 1]
을로 매핑하는 함수입니다
[-inf, +inf]
.
소프트 맥스는
매핑 함수
[-inf, +inf]
에
[0, 1]
S 상 유사한. 그러나 Softmax는 또한 값 (출력 벡터)의 합을 1로 정규화합니다.
Tensorflow "with logit"
: 소프트 맥스 함수를 적용하여 숫자를 로트하여 정규화합니다. input_vector / logit는 정규화되지 않았으며 [-inf, inf]에서 확장 할 수 있습니다.이 정규화는 다중 클래스 분류 문제에 사용됩니다. 그리고 멀티 라벨 분류 문제의 경우 시그 모이 드 정규화가 사용됩니다.
tf.nn.sigmoid_cross_entropy_with_logits
이 해명을 추가하면 아래로 스크롤하는 사람은 적어도 잘못된 답변이 많이 나오기 때문에 적어도 올바르게 얻을 수 있습니다.Diansheng의
과 JakeJ의
이 맞습니다. Shital Shah가 게시
은 더 좋고 완전한 답변입니다.
그렇습니다. 통계에서
logit
수학적
로 사용
되지만 logit
신경망의 맥락 에서 사용되는 것은 다릅니다.
통계
logit
는 여기에서도 의미가 없습니다.
나는 어디에서나 공식적인 정의를 찾을 수 없었지만
logit
기본적으로 다음을 의미합니다.
신경망의 마지막 계층에서 나오는 원시 예측.1. 이것은 예측 클래스를 얻기 위해 함수를 적용하는 매우 텐서입니다 .
2. 이것은 예측 된 클래스에 대한 확률을 얻기 위해 함수에 피드하는 매우 텐서입니다 .
또한 공식 tensorflow 웹 사이트 의
에서
로짓 층
신경망의 마지막 계층은 로짓 계층으로 예측의 원시 값을 반환합니다. 선형 활성화 (기본값)를 사용하여 10 개의 뉴런 (각 대상 클래스 0–9에 대해 하나씩)으로 조밀 한 레이어를 만듭니다.logits = tf.layers.dense(inputs=dropout, units=10)
여전히 혼란 스러우면 상황은 다음과 같습니다.
raw_predictions = neural_net(input_layer)
predicted_class_index_by_raw = argmax(raw_predictions)
probabilities = softmax(raw_predictions)
predicted_class_index_by_prob = argmax(probabilities)
여기서,
predicted_class_index_by_raw
와
predicted_class_index_by_prob
동일 할 것이다.
raw_predictions
위 코드에서 다른 이름 은logit
입니다.
그 이유는 logit
... 나는 모른다. 죄송합니다.
[편집 :
용어의 역사적 동기에 대해서는 이 답변 을 참조하십시오 .]
하찮은 일
원하는 경우 함수에서 나오는 통계
logit
를 적용 할 수 있습니다 .
probabilities
softmax
특정 클래스의 가능성이있는 경우
p
,
그 다음
로그 확률
이 클래스의입니다
L = logit(p)
.또한 함수를
p = sigmoid(L)
사용하여 해당 클래스의 확률을로 복구 할 수 있습니다
.그러나 로그 홀수를 계산하는 데별로 유용하지 않습니다.
요약
딥 러닝과 관련하여
는 소프트 맥스 (또는 다른 정규화)로 공급되는 레이어를 의미합니다. softmax의 출력은 분류 작업의 확률이며 입력은 로짓 레이어입니다. 로짓 레이어는 일반적으로 -infinity에서 + infinity까지의 값을 생성하고 softmax 레이어는이를 0에서 1까지의 값으로 변환합니다.
역사적 맥락
Where does this term comes from? In 1930s and 40s, several people were trying to adapt linear regression to the problem of predicting probabilities. However linear regression produces output from -infinity to +infinity while for probabilities our desired output is 0 to 1. One way to do this is by somehow mapping the probabilities 0 to 1 to -infinity to +infinity and then use linear regression as usual. One such mapping is cumulative normal distribution that was used by Chester Ittner Bliss in 1934 and he called this "probit" model, short for "probability unit". However this function is computationally expensive while lacking some of the desirable properties for multi-class classification. In 1944 Joseph Berkson used the function log(p/(1-p))
to do this mapping and called it logit, short for "logistic unit". The term logistic regression derived from this as well.
The Confusion
Unfortunately the term logits is abused in deep learning. From pure mathematical perspective logit is a function that performs above mapping. In deep learning people started calling the layer "logits layer" that feeds in to logit function. Then people started calling the output values of this layer "logit" creating the confusion with logit the function.
TensorFlow Code
Unfortunately TensorFlow code further adds in to confusion by names like tf.nn.softmax_cross_entropy_with_logits
. What does logits mean here? It just means the input of the function is supposed to be the output of last neuron layer as described above. The _with_logits
suffix is redundant, confusing and pointless. Functions should be named without regards to such very specific contexts because they are simply mathematical operations that can be performed on values derived from many other domains. In fact TensorFlow has another similar function sparse_softmax_cross_entropy
where they fortunately forgot to add _with_logits
suffix creating inconsistency and adding in to confusion. PyTorch on the other hand simply names its function without these kind of suffixes.
Reference
The Logit/Probit lecture slides is one of the best resource to understand logit. I have also updated Wikipedia article with some of above information.
Personal understanding, in TensorFlow domain, logits are the values to be used as input to softmax. I came to this understanding based on this tensorflow tutorial.
https://www.tensorflow.org/tutorials/layers
Although it is true that logit is a function in maths(especially in statistics), I don't think that's the same 'logit' you are looking at. In the book Deep Learning by Ian Goodfellow, he mentioned,
The function σ−1(x) is called the logit in statistics, but this term is more rarely used in machine learning. σ−1(x) stands for the inverse function of logistic sigmoid function.
In TensorFlow, it is frequently seen as the name of last layer. In Chapter 10 of the book Hands-on Machine Learning with Scikit-learn and TensorFLow by Aurélien Géron, I came across this paragraph, which stated logits
layer clearly.
note that
logits
is the output of the neural network before going through the softmax activation function: for optimization reasons, we will handle the softmax computation later.
That is to say, although we use softmax as the activation function in the last layer in our design, for ease of computation, we take out logits
separately. This is because it is more efficient to calculate softmax
and cross-entropy
loss together. Remember that cross-entropy
is a cost function, not used in forward propagation.
Here is a concise answer for future readers. Tensorflow
's logit
is defined as the output of a neuron without applying activation function:
logit = w*x + b,
x: input, w: weight, b: bias. That's it.
The following is irrelevant to this question.
For historical lectures, read other answers. Hats off to Tensorflow
's "creatively" confusing naming convention. In PyTorch
, there is only one CrossEntropyLoss
and it accepts un-activated outputs. Convolutions, matrix multiplications and activations are same level operations. The design is much more modular and less confusing. This is one of the reasons why I switched from Tensorflow
to PyTorch
.
They are basically the fullest learned model you can get from the network, before it's been squashed down to apply to only the number of classes we are interested in. Check out how some researchers use them to train a shallow neural net based on what a deep network has learned: https://arxiv.org/pdf/1312.6184.pdf
It's kind of like how when learning a subject in detail, you will learn a great many minor points, but then when teaching a student, you will try to compress it to the simplest case. If the student now tried to teach, it'd be quite difficult, but would be able to describe it just well enough to use the language.
The logit (/ˈloʊdʒɪt/ LOH-jit) function is the inverse of the sigmoidal "logistic" function or logistic transform used in mathematics, especially in statistics. When the function's variable represents a probability p, the logit function gives the log-odds, or the logarithm of the odds p/(1 − p).
See here: https://en.wikipedia.org/wiki/Logit
(FOMOsapiens).
If you check math Logit function, it converts real space from [0,1]
interval to infinity [-inf, inf]
.
Sigmoid and softmax will do exactly the opposite thing. They will convert the [-inf, inf]
real space to [0, 1]
real space.
This is why it has sense in machine learning we may use logit before sigmoid and softmax function (since they match).
And this is why "we may call" anything in machine learning that goes in front sigmoid or softmax function the logit.
Here is J. Hinton video usign this term.
PS. I am not recommending you to watch the video just to check on the term.
Logits often are the values of Z function of the output layer in Tensorflow.
참고 URL :
https://stackoverflow.com/questions/41455101/what-is-the-meaning-of-the-word-logits-in-tensorflow
'programing' 카테고리의 다른 글
PHP에서 객체의 속성을 삭제할 수 있습니까? (0) | 2020.05.20 |
---|---|
C ++에서 '재정의'키워드는 무엇에 사용됩니까? (0) | 2020.05.20 |
PHP에서 이중 (!!) 연산자 (0) | 2020.05.20 |
넘친 내용으로 flexbox 스크롤 (0) | 2020.05.20 |
SQL Server Management Studio 2008에서 모든 테이블을 검색하여 문자열 찾기 (0) | 2020.05.19 |