Skip to content

Commit

Permalink
modify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin-Ying committed Aug 31, 2020
1 parent fec95db commit 9907bd9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions dalib/adaptation/mcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ class MinimumClassConfusionLoss(nn.Module):
Given classifier predictions (logits before softmax) :math:`Z`, the definition of MCC loss is
.. math::
{\widehat Y_{ij}} = \frac{{\exp \left( {{Z_{ij}}/T} \right)}}{{\sum\nolimits_{j' = 1}^{|{\mathcal{C}}|}
{\exp \left( {{Z_{ij'}}/T} \right)} }},
where :math:`T` is the temperature for rescaling,
{{\mathbf{C}}_{jj'}} = {\widehat{\mathbf{y}}}_{ \cdot j}^{\sf T}{{\widehat{\mathbf{y}}}_{ \cdot j'}},
H(\widehat{\bf y}_{i\cdot})= - { \sum _{j=1 }^{ |{\cal {C}}| }{ { \widehat { Y } }_{ ij }\
log{ \widehat { Y } }_{ ij } } },
{{\mathbf{C}}_{jj'}} = {\widehat{\mathbf{y}}}_{ \cdot j}^{\sf T}{\mathbf{W}}{{\widehat{\mathbf{y}}}_{ \cdot j'}},\\
where the weighting scheme is
{W_{ii}} = \frac{{B\left( {1 + \exp ( { - H( {{{{\widehat{\bf y}}}_{i \cdot }}} )} )} \right)}}
{{\sum\limits_{i' = 1}^B {\left( {1 + \exp ( { - H( {{{{\widehat{\bf y}}}_{i' \cdot }}} )} )} \right)} }},
{{\mathbf{C}}_{jj'}} = {\widehat{\mathbf{y}}}_{ \cdot j}^{\sf T}{\mathbf{W}}{{\widehat{\mathbf{y}}}_{ \cdot j'}}.
where H denotes the entropy function.\\
We adopt entropy function to alleviate class imbalance,
{{{\widetilde{\mathbf C}}}_{jj'}} = \frac{{{{\mathbf{C}}_{jj'}}}}{{\sum\nolimits_{{j''} = 1}^
{|{\mathcal{C}}|} {{{\mathbf{C}}_{j{j''}}}} }},
MCC aims at minimizing cross-class confusion,
{L_{{\rm{MCC}}}} ( {{{\widehat {\mathbf{Y}}}_t}} ) = \frac{1}{|{\cal {C}}|}\sum\limits_{j = 1}^
{|{\mathcal{C}}|} {\sum\limits_{j' \ne j}^{|{\mathcal{C}}|} {\left| {{{{\widetilde{\mathbf C}}}_{jj'}}} \right|} }.
Expand Down

0 comments on commit 9907bd9

Please sign in to comment.