<>BCELoss

When images are classified by multiple tags , If 3 Pictures 3 class , One will be output 3*3 Matrix of .

First use Sigmoid Get these values 0~1 between :

hypothesis Target yes :

BCELoss yes − 1 n ∑ ( y n × ln ⁡ x n + ( 1 − y n ) × ln ⁡ ( 1 − x n ) ) -\frac 1
n\sum(y_n \times \ln x_n+(1-y_n) \times \ln(1-x_n))−n1​∑(yn​×lnxn​+(1−yn​)×ln(1−
xn​))
among y yes target,x Is the value of the model output .
So for the first line :
First column 0 × ln ⁡ 0.3992 + ( 1 − 0 ) × ln ⁡ ( 1 − 0.3992 ) = − 0.5095 0 \times \ln
0.3992+ (1-0) \times \ln (1-0.3992)=-0.50950×ln0.3992+(1−0)×ln(1−0.3992)=−0.5095
Second column 1 × ln ⁡ 0.2232 + ( 1 − 1 ) × ln ⁡ ( 1 − 0.2232 ) = − 1.4997 1 \times \ln
0.2232+ (1-1) \times \ln (1-0.2232)=-1.49971×ln0.2232+(1−1)×ln(1−0.2232)=−1.4997
Third column 1 × ln ⁡ 0.6435 + ( 1 − 1 ) × ln ⁡ ( 1 − 0.6435 ) = − 0.4408 1 \times \ln
0.6435+ (1-1) \times \ln (1-0.6435)=-0.44081×ln0.6435+(1−1)×ln(1−0.6435)=−0.4408
The second line :
First column 0 × ln ⁡ 0.3800 + ( 1 − 0 ) × ln ⁡ ( 1 − 0.3800 ) = − 0.4780 0 \times \ln
0.3800+ (1-0) \times \ln (1-0.3800)=-0.47800×ln0.3800+(1−0)×ln(1−0.3800)=−0.4780
Second column 0 × ln ⁡ 0.3044 + ( 1 − 0 ) × ln ⁡ ( 1 − 0.3044 ) = − 0.3630 0 \times \ln
0.3044+ (1-0) \times \ln (1-0.3044)=-0.36300×ln0.3044+(1−0)×ln(1−0.3044)=−0.3630
Third column 1 × ln ⁡ 0.3241 + ( 1 − 1 ) × ln ⁡ ( 1 − 0.3241 ) = − 1.1267 1 \times \ln
0.3241+ (1-1) \times \ln (1-0.3241)=-1.12671×ln0.3241+(1−1)×ln(1−0.3241)=−1.1267
The third line :
First column 1 × ln ⁡ 0.6281 + ( 1 − 1 ) × ln ⁡ ( 1 − 0.6281 ) = − 0.4651 1 \times \ln
0.6281+ (1-1) \times \ln (1-0.6281)=-0.46511×ln0.6281+(1−1)×ln(1−0.6281)=−0.4651
Second column 0 × ln ⁡ 0.4689 + ( 1 − 0 ) × ln ⁡ ( 1 − 0.4689 ) = − 0.6328 0 \times \ln
0.4689+ (1-0) \times \ln (1-0.4689)=-0.63280×ln0.4689+(1−0)×ln(1−0.4689)=−0.6328
Third column 1 × ln ⁡ 0.3834 + ( 1 − 1 ) × ln ⁡ ( 1 − 0.3834 ) = − 0.9587 1 \times \ln
0.3834+ (1-1) \times \ln (1-0.3834)=-0.95871×ln0.3834+(1−1)×ln(1−0.3834)=−0.9587
Remove the negative sign and find the mean value :
0.5095 + 1.4997 + 0.4408 3 = 0.8167 \frac {0.5095+1.4997+0.4408} {3} = 0.8167
30.5095+1.4997+0.4408​=0.8167
0.4780 + 0.3630 + 1.1267 3 = 0.6559 \frac {0.4780+0.3630+1.1267} {3} = 0.6559
30.4780+0.3630+1.1267​=0.6559
0.4651 + 0.6328 + 0.9587 3 = 0.6855 \frac {0.4651+0.6328+0.9587} {3} = 0.6855
30.4651+0.6328+0.9587​=0.6855
Take an average again :
0.8167 + 0.6559 + 0.6855 3 = 0.7194 \frac {0.8167+0.6559+0.6855} {3} = 0.7194
30.8167+0.6559+0.6855​=0.7194
Let's use BCELoss To verify it Loss Right? 0.7194!

emmm It should be that I keep it every time 4 Decimal place , At the end of the calculation, the error is getting worse and worse 0.0001. But it's also very powerful. Ha ha ha ha ha !

<>BCEWithLogitsLoss

BCEWithLogitsLoss That is to say Sigmoid-BCELoss Synthesis step . We're going to use it directly input Check it out 0.7193:

Hee hee , I'm so good !

If you think I'm good, too , Please give me a reward to encourage me to do better , Thank you very much. !

Technology