error with Input data sizes in using sim

1 次查看(过去 30 天)
Hi i write this code
but i have a problem when i use sim it has an error that "Input data sizes do not match net.inputs{1}.size."
I am new to ANN and i don't know what should i do
clc;clear all ; close all
%% Import Data
filename = 'zafar_queue.csv'; % abc = name of data file
flow_data = csv2struct(filename);
%% Variables
Y = flow_data.nVehContrib;
data = Y';
periods = flow_data.begin;
dates = seconds(periods);
trn = floor(0.95*(length(data)));
data_train = data(1:trn);
data_test = data(trn+1:end);
trnX = data_train(1:end);
trnY = data_train(1:end);
trndates = dates(1:trn);
testX = data_test(1:end);
testY = data_test(1:end);
testdates = dates(trn+1:end);
%% Neural (Model)
net = newfit(trnX',trnY',30);
[net,tr] = train(net, trnX', trnY');
%% Forecast and error
load_forecast = sim(net,testX)';
% err = testY - load_forecast;
% errp = (abs(err)./testY)*100;
%
% mae = mean(testY, load_forecast);
% mape = mean(errp);
%% Figures
h2 = figure;
plot(testY,'DisplayName','testY');hold on;plot(load_forecast,'DisplayName','forecast');hold off;
ylabel('Load');
h3 = figure;
plot(testdates, testY - load_forecast);
xlabel('Date'); ylabel('Error');

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by