Sequence CNN with different input and output size

7 vues (au cours des 30 derniers jours)
Yesid Fonseca Vargas
Yesid Fonseca Vargas le 6 Fév 2021
I'm trying to train a Regression Sequence CNN with the following properties:
  1. All training input sequences have length L
  2. All training output sequences have length LOut with LOut <= L
By default MATLAB requires that L = LOut and the training is really good when L=LOut. Then I was trying to fix the case LOut<L by filling the output sequence of training with zeros but the training does not converge. Then I was trying to construct a Custom Regression Layer where the loss function only considers the values between 1 to LOut but again there's no training convergence. Then I tried to construct a Custom Fully Connected Layer but the Checking Layer Process fails, I think that the Checking process fails because matlab does 2 checking stages where the size of the sequence input varies between 1 and 3 (I checked it with the debugger) and since the learnable weights have a fixed sice the Checking process fails in the multiplication and sum operations .
Any sugestion?
Adjoint the predict function of each Custom layer:
Regression Layer
function loss = forwardLoss(layer, Y, T)
LOut_ = layer.LOut;
meanAbsoluteError = sum(abs(Y(:,:,1:LOut_)-T(:,:,1:LOut_,R)),3)/LOut_;
% Take mean over mini-batch.
N = size(Y,4);
loss = sum(meanAbsoluteError)/N;
end
Fully Connected Layer
function [Z] = predict(layer,X)
[l,m,n]=size(X); %m is ne number of features and n is the length of the sequences. l is usually the minibatch size.
mBS = size(X,2);
LOut_ = layer.LOut;
W_=layer.W;
b_= layer.b;
Z = zeros(l,m,LOut_);
for i = 1:l
Z(i,:,:) = (W_*squeeze(X(i,:,:))'+b_)';
end
end

Réponses (1)

Raynier Suresh
Raynier Suresh le 19 Fév 2021
Hi, You can try an encoder decoder model to achieve this. The below example explains you about how to set an encoder decoder model for sequence to sequence translation.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by