Managing different lengths in time series for sequence-to-sequence classification.

5 次查看(过去 30 天)
Hello,
I would like to ask a general opinion regarding the example displayed in:
In order to manage different lengths in a mini-batch of training data the example implement a left zero padding adding vectors of zero at the left of both accelerometric data and relative responses.
In this way the resulting sequences are:
Subsequently in the evaluation of the training loss the function:
function loss = maskedCrossEntropyLoss(dlY, dlT, numTimeSteps)
numObservations = size(dlY,2);
loss = dlarray(zeros(1,numObservations,'like',dlY));
for i = 1:numObservations
idx = 1:numTimeSteps(i);
loss(i) = crossentropy(dlY(:,i,idx),dlT(:,i,idx),'DataFormat','CBT');
end
end
Evaluate the loss on the first idx samples of the padded sequences where idx represent the real (not padded) number of time samples of the data. However since idx goes to 1:numTimeSteps just the first time samples are considered, from left to right includind the padded samples of zeros. I would, instead, evaluate the last samples:
idx = size(dlY,3)-numTimeSteps(i)+1:size(dlY,3);
loss(i) = crossentropy(dlY(:,i,idx),dlT(:,i,idx),'DataFormat','CBT');
Is this a correct consideration or i am losing something?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by