How do i fix error : 'model' parameter must be a character vector?
70 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Bonaventura Sanjoyo
el 15 de Ag. de 2019
Comentada: Walter Roberson
el 12 de Ag. de 2020
Hi everyone, sorry for asking this silly question. since i'm really new in nn matlab, i'm having difficulties to implement nn in matlab. so that you all can understand the bigger picture of what trouble i might have come across, i'm gonna give it in details.
first that i have data in xls document, each xls document contain 24 rows of data with 3 parameters (perimeter, diameter and area) of fruit database. this data is already a post-processed image (from preprocessing i saved the data in excel). then i normalized the data,
data1 = data1';
max_data = max(max(data1));
min_data = min(min(data1));
[m,n] = size(data1);
data_norm = zeros(m,n);
for x = 1:m
for y = 1:n
data_norm(x,y) = 0.1+0.8*(data1(x,y)-min_data)/(max_data-min_data);
end
end
afterward i use patternnet to train my data so that it can identify what kind of fruit i input to the gui system. it roughly like this :
net.trainFcn = 'trainlm';
net = patternnet(100, 'trainlm');
net.trainParam.epochs = 1000;
net.trainParam.goal = 1e-5;
net.divideFcn = 'dividerand'; % num of data that'll be divide
net.divideParam.trainRatio = 70/100; % training set
net.divideParam.valRatio = 15/100; % validation set
net.divideParam.testRatio = 15/100; % testing set
net = init(net);
[net,tr] = train(net, data_norm,group);
y = sim(net, data_norm);
....
%then classification from input and net to get classification fruit class...
....
result = round(sim(y,sample));
....
switch result
case 0
class='Firm';
case 1
class='Ripe';
case 2
class='Overripe';
end
so, i assume that from normalising the data, making the shape of the data change. How do i fix this? i search it online on MATLABanswers forum and someone have the same problem (not really the same) and the suggestion is this
but when i try it, my nn doesn't want to run and didn't display the nntraintool. What should i do to fix it?
2 comentarios
Respuesta aceptada
Walter Roberson
el 16 de Ag. de 2019
[net,tr] = train(net, data_norm,group);
y = sim(net, data_norm);
y is going to be numeric and the same size as group
result = round(sim(y,sample));
There you are sim() on that numeric value. You need to sim() on a network.
You do not need to sim() on the original data unless you want to cross-check the accuracy of the network. The train() call already returns a network that knows the (approximate) classification rules, so you would
result = round(sim(net,sample));
Más respuestas (1)
Xin Yee Tai
el 12 de Ag. de 2020
Instead of 'sim', please try 'predict'.
Hope it helps!
3 comentarios
Xin Yee Tai
el 12 de Ag. de 2020
Hi, thanks for correcting me. Could you please explain more about the different use between sim and predict? Thank you !
Walter Roberson
el 12 de Ag. de 2020
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!