필터 지우기
필터 지우기

clamp cross-entropy loss

조회 수: 3 (최근 30일)
Matt Fetterman
Matt Fetterman 2020년 9월 3일
댓글: Matt Fetterman 2020년 9월 6일
the Matlab cross-entropy loss has this form:
loss = -sum(W*(T.*log(Y)))/N;
I would like to "clamp" it so that the log function output is bounded, for example it cannot be less than 100.
Can we do it?

채택된 답변

David Goodmanson
David Goodmanson 2020년 9월 3일
편집: David Goodmanson 2020년 9월 6일
Hi Matt,
z = log(Y);
z(z<100) = 100;
loss = -sum(W*(T.*z))/N;
In the link you provided, they talk about a limit of -100 rather than +100. The former appears to make more sense. Lots of possibilities for a smooth differentiable cutoff, here is one, assuming Y>=0
Ylimit = -100;
loss = -sum(W*(T.*log(Y+exp(Ylimit)))/N;
  댓글 수: 3
David Goodmanson
David Goodmanson 2020년 9월 6일
Hi Matt,
see amended answer.
Matt Fetterman
Matt Fetterman 2020년 9월 6일
probably a smart approach.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by