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!