TDNN for EMG signal analysis giving this error: "Inputs and targets have different numbers of timesteps." Help?
조회 수: 1 (최근 30일)
이전 댓글 표시
Basically title. We have tried multiple fixes, and changes but we keep getting this error. However, they are of the same timesteps. Could anyone help please?
%% Get Data
%Import Excel File
filename='test1.csv';
data=readmatrix(filename,'NumHeaderLines',1);
%Assign to variable
x=[data(1:63196,1:9)];
X=con2seq(x);
t=[data(1:63196,1) data(1:63196,10)];
T=con2seq(t);
%% Create TDNN
delay = 1:2;
neurons =10;
net=timedelaynet(delay,neurons);
net=configure(net,X,T);
net.numinputs = 8;
net.trainParam.epochs=30;
net=train(net,X,T);
%% Predictions
outputs=net(X);
%% Evaluation
performance=perform(net,T,outputs); %needs to be altered to test it on untrained data
댓글 수: 0
답변 (1개)
Venu
2024년 2월 15일
편집: Venu
2024년 2월 16일
Try reshaping x,t before converting them into sequences.This ensures that each column of the matrices became a separate sequence, which is the expected format for a TDNN in MATLAB.
%% Get Data
% Import Excel File
filename = 'test1.csv';
data = readmatrix(filename, 'NumHeaderLines', 1);
% Assign to variable
x = data(1:63196, 1:9);
r1 = length(x);
c1 = size(x, 2);
x = reshape(x, c1, r1);
X = con2seq(x);
t = [data(1:63196, 1) data(1:63196, 10)];
r2 = length(t);
c2 = size(t, 2);
t = reshape(t, c2, r2);
T = con2seq(t);
I reshaped your input (x) and target (t) matrices such that each feature and target becomes a separate sequence. This is done by transposing the matrices so that they have dimensions where rows represent features and columns represent timesteps. You can try using transpose operator also (non-conjugate transpose in your case).
Hope this helps!
참고 항목
카테고리
Help Center 및 File Exchange에서 Pattern Recognition and Classification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!