About neural network : newbie question

I am a new to matlab. I just covert my image to matrix and want to train it. here is my coding:
P= [];
for i =1:15
str=strcat('E:Skripsi\crop2\image',int2str(i),'.bmp');
eval('img=imread(str);');
img=reshape(img,[],1);
P= [P img];
end
T=[1 1 1 1 1 1 1 1 1 1 0 0 0 0 0];// if true image i make it 1 , negative image make it 0
p = num2cell(P,1);
t = num2cell(T,1);
net = newff(minmax(p), [3 1], {'logsig' 'purelin'});
net.trainParam.epochs = 10;
net = train(net,p,t);
Y=sim(net,p)
these is what i got when i compile it
[0.9794] [0.9974] [1.2784] [1.0014] [1.0058] [0.9904] [0.7293] [1.0001] [1.0106]
Columns 10 through 15
[1.0002] [0.0618] [3.3131e-04] [9.9559e-04] [0.0134] [0.0178]
then my problem is what should i do to make the result success i train in percentage with error below 1% (what i want: example i train 10 true image to 1 and one result of my train is 0.798 then accurate =90%) thanks for the help.

 Respuesta aceptada

Greg Heath
Greg Heath el 19 de Dic. de 2013

1 voto

There is no reason to use cells or only train for 10 epochs.
Use round to convert the output to {0,1}
Thank you for formally accepting my answer
Greg

5 comentarios

Parkz Leingodz
Parkz Leingodz el 19 de Dic. de 2013
Editada: Parkz Leingodz el 19 de Dic. de 2013
firstly thanks for your guidence, i'm still don't understand with "no reason to use cells " so what should i do for best? do you have better solution? because i tried once without cell and it wents error "inputs are not a matrix or cell array with a single matrix" thank you for kindly help
Greg Heath
Greg Heath el 19 de Dic. de 2013
No reason to use cells: Just use P and T instead of p and t.
You have successfully gotten a cell answer with non-integer values. However, to get {0,1} you have to use cell2mat and then round. So why use cells in the first place?
I cannot answer your last question because I haven't see your noncell code. What dimension is P?
here is my non cellcode at first :
P= [];
for i =1:15
str=strcat('E:Skripsi\crop2\image',int2str(i),'.bmp');
eval('img=imread(str);');
img=reshape(img,[],1);
P= [P img];% convert all the image to one matrix
end
T=[1 1 1 1 1 1 1 1 1 1 0 0 0 0 0];
net = newff(minmax(P), [3 1], {'logsig' 'purelin'});
net.trainParam.epochs = 10;
net = train(net,P,T);
Y=sim(net,P)
and if i compile it , here is the error :
Error using newff>new_5p0 (line 257)
Inputs are not a matrix or cell array with a single matrix.
Error in newff>create_network (line 128)
net = new_5p0(varargin{:});
Error in newff (line 102)
out1 = create_network(varargin{:});
Error in f (line 12)
net = newff(minmax(P), [3 1], {'logsig' 'purelin'});
actually i don't know how to fix this error and where's the error, so i just try to change P to cell and it works.
but what u mention earlier is true, i have to change cell2mat when i want get {0,1}. so do you have an advice to fix my non cell code?
i don't know how to answer what dimension P is. i just want to convert image to one matrix and train it. thanks
Greg Heath
Greg Heath el 19 de Dic. de 2013
whos P
size(P)
Parkz Leingodz
Parkz Leingodz el 20 de Dic. de 2013
size P is 16x21 pixels.
P is a matrix that save whole matrix value of img.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Dic. de 2013

Comentada:

el 20 de Dic. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by