How to replace the one-hot-encoded label with a (Gaussian) distribution in the training of a CNN for classification ?

조회 수: 12 (최근 30일)
Hi there,
I am trying to train a CNN for classification using imagedatastore, in which the cross entropy loss needs to be calculated between the softmax output and a (Gaussian) distribution instead of its one-hot-encoded version of the label.
In case I need to customize Matlab functions such that my own function (that converts an original label into a distribution) runs instead of 'onehotencode', where (or in which function) does this 'onehotencode' run ?
There may be other simpler ways to achieve my goal. I would greatly appreciate if anyone could help me on this.
Best regards,
HK

답변 (1개)

yanqi liu
yanqi liu 2022년 1월 24일
yes,sir,may be just compute vector,such as
class_info = [1; 2; 2; 1]
class_info = 4×1
1 2 2 1
class_num = length(unique(class_info));
Y = zeros(length(class_info), class_num);
for i = 1 : length(class_info)
Y(i, class_info(i)) = 1;
end
Y
Y = 4×2
1 0 0 1 0 1 1 0
  댓글 수: 3
yanqi liu
yanqi liu 2022년 1월 27일
yes,it is same question i faced,may be can not make multi output in this environment,so just use label value. but in TensorFlow or Pytorch,it is easy to make multi output,and just add loss can train model
hyeonjin kim
hyeonjin kim 2022년 1월 27일
Dear Yanqi, thanks very much for sharing your thoughts. I will try some more to tackle this issue, but might ultimately have to go for Pytorch, for instance, as you told.
Best !

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

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by