HI!
I have an image 30/30 pixels and I want to restore it using
backpropogation. When I indicate the input of the network as
a matrix:
K=mat2gray(J);
everything goes well. But I want to try to have not a matrix
input, but an array one.For example:
L=reshape(K,1,900);
But in this case I have problems with network architecture.
It creates in the first layer only one neuron and the
experiments have no sense in this case.
Can anybody tell me what's wrong here?
This is what I get:
I4 = imread('Sb-4.jpg'); J4 = rgb2gray(I4); K4 =
mat2gray(J4); L4 = reshape(K4,1,900);
IE4 = imread('ESb4.jpg'); JE4 = rgb2gray(IE4); KE4 =
mat2gray(JE4); LE4 = reshape(KE4,1,900);
p=[L4]';
t=[LE4]';
net=newff([01],[1,900],{'logsig','logsig'},'trainrp','learngdm','mse');
net.trainParam.epochs=200;
net.trainparam.goal=0;
net.trainParam.show=25;
net.trainParam.Gradient=0;
net=init(net);
[net,tr]=train(net,p,t);
??? Error using ==> network.train
Inputs are incorrectly sized for network.
Matrix must have 1 rows.
If I change like:
net=newff(minmax(p),[1,900],{'logsig','logsig'},'trainrp','learngdm','mse');
Warning: Divide by zero.
What is the purpose of that [01] ?? Matlab is going to interpret
that as a 1 written with an unnecessary leading 0, and so treat
[01] as equivilent to [1] (which is also equivilent in Matlab to
1 without the [] around it.)
Did you mean [0 1] ?
--
"I was very young in those days, but I was also rather dim."
-- Christopher Priest
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <g4o0em$ikc$1@canopus.cc.umanitoba.ca>...
> In article <g4nrg2$asi$1@fred.mathworks.com>,
> Olga Ghincul <olea_san@yahoo.com> wrote:
>
>
>net=newff([01],[1,900],{'logsig','logsig'},'trainrp','learngdm','mse');
>
> What is the purpose of that [01] ?? Matlab is going to
interpret
> that as a 1 written with an unnecessary leading 0, and so
treat
> [01] as equivilent to [1] (which is also equivilent in
Matlab to
> 1 without the [] around it.)
>
> Did you mean [0 1] ?
> --
> "I was very young in those days, but I was also rather
dim."
> -- Christopher Priest
Yes, I meant [0 1] but my problem is that I do not
understant clearly what the architecture should look like...
On Jul 5, 9:04=A0am, "Olga Ghincul" <olea_...@yahoo.com> wrote:
> HI!
> I have an image 30/30 pixels and I want to restore it using
> backpropogation. When I indicate the input of the network as
> a matrix:
> K=3Dmat2gray(J);
> everything goes well. But I want to try to have not a matrix
> input, but an array one.For example:
> L=3Dreshape(K,1,900);
> But in this case I have problems with network architecture.
> It creates in the first layer only one neuron and the
> experiments have no sense in this case.
> Can anybody tell me what's wrong here?
> This is what I get:
>
> I4 =3D imread('Sb-4.jpg'); J4 =3D rgb2gray(I4); K4 =3D
> mat2gray(J4);
I'm not familiar with these functions. However, judging
from their names it seems strange that mat2gray
would follow rgb2gray.
You probably can delete the above 5 commands.
See the defaults in
help newff
Also,
net =3D newff (...) results in automatic initialization.
> [net,tr]=3Dtrain(net,p,t);
> ??? Error using =3D=3D> network.train
> Inputs are incorrectly sized for network.
> Matrix must have 1 rows.
>
> If I change like:
> net=3Dnewff(minmax(p),[1,900],{'logsig','logsig'},'trainrp','learngdm','m=
se')=AD;
> Warning: Divide by zero.
Greg Heath <heath@alumni.brown.edu> wrote in message
<2899e6ec-c83d-4eb3-9441-42dff1be23c7@y21g2000hsf.googlegroups.com>...
> On Jul 5, 9:04=A0am, "Olga Ghincul" <olea_...@yahoo.com>
wrote:
> > HI!
> > I have an image 30/30 pixels and I want to restore it using
> > backpropogation. When I indicate the input of the network as
> > a matrix:
> > K=3Dmat2gray(J);
> > everything goes well. But I want to try to have not a matrix
> > input, but an array one.For example:
> > L=3Dreshape(K,1,900);
> > But in this case I have problems with network architecture.
> > It creates in the first layer only one neuron and the
> > experiments have no sense in this case.
> > Can anybody tell me what's wrong here?
> > This is what I get:
> >
> > I4 =3D imread('Sb-4.jpg'); J4 =3D rgb2gray(I4); K4 =3D
> > mat2gray(J4);
>
> I'm not familiar with these functions. However, judging
> from their names it seems strange that mat2gray
> would follow rgb2gray.
>
> > L4 =3D reshape(K4,1,900);
> > IE4 =3D imread('ESb4.jpg'); JE4 =3D rgb2gray(IE4); KE4 =3D
> > mat2gray(JE4); LE4 =3D reshape(KE4,1,900);
> > p=3D[L4]';
> > t=3D[LE4]';
>
> size(t) =3D size(p) =3D [ 900 1]
>
> >
net=3Dnewff([01],[1,900],{'logsig','logsig'},'trainrp','learngdm','mse');
>
> Space missing. I think you meant [ 0 1].
>
> Nevertheless, you transposed L4 so you really need
>
> repmat([0 1],900,1).
>
> Better to use minmax(p).
>
> [1 900] =3D=3D> 1 Hidden node and 900 output nodes.
>
> Try [ H 900 ]
>
> > net.trainParam.epochs=3D200;
> > net.trainparam.goal=3D0;
> > net.trainParam.show=3D25;
> > net.trainParam.Gradient=3D0;
> > net=3Dinit(net);
>
> You probably can delete the above 5 commands.
> See the defaults in
>
> help newff
>
> Also,
>
> net =3D newff (...) results in automatic initialization.
>
> > [net,tr]=3Dtrain(net,p,t);
> > ??? Error using =3D=3D> network.train
> > Inputs are incorrectly sized for network.
> > Matrix must have 1 rows.
> >
> > If I change like:
> >
net=3Dnewff(minmax(p),[1,900],{'logsig','logsig'},'trainrp','learngdm','m=
> se')=AD;
> > Warning: Divide by zero.
>
> Can't help you with that one.
>
> Hope that helps.
>
> Greg
>
Thank's for some hints. In fact I tried to get a result all
the day but I failed. How do you think in what way the
network would train better, if we have a matrix or an array
as input?
On Jul 5, 1:02=A0pm, "Olga Ghincul" <olea_...@yahoo.com> wrote:
> Greg Heath<he...@alumni.brown.edu> wrote in message
>
> <2899e6ec-c83d-4eb3-9441-42dff1be2...@y21g2000hsf.googlegroups.com>...
>
>
>
> > On Jul 5, 9:04=3DA0am, "Olga Ghincul" <olea_...@yahoo.com>
> wrote:
> > > HI!
> > > I have an image 30/30 pixels and I want to restore it using
> > > backpropogation. When I indicate the input of the network as
> > > a matrix:
> > > K=3D3Dmat2gray(J);
> > > everything goes well. But I want to try to have not a matrix
> > > input, but an array one.For example:
> > > L=3D3Dreshape(K,1,900);
> > > But in this case I have problems with network architecture.
> > > It creates in the first layer only one neuron and the
> > > experiments have no sense in this case.
> > > Can anybody tell me what's wrong here?
> > > This is what I get:
>
> > > I4 =3D3D imread('Sb-4.jpg'); J4 =3D3D rgb2gray(I4); K4 =3D3D
> > > mat2gray(J4);
>
> > I'm not familiar with these functions. However, judging
> > from their names it seems strange that mat2gray
> > would follow rgb2gray.
>
> > > L4 =3D3D reshape(K4,1,900);
> > > IE4 =3D3D imread('ESb4.jpg'); JE4 =3D3D rgb2gray(IE4); KE4 =3D3D
> > > mat2gray(JE4); LE4 =3D3D reshape(KE4,1,900);
> > > p=3D3D[L4]';
> > > t=3D3D[LE4]';
>
> > size(t) =3D3D size(p) =3D3D [ 900 1]
>
> net=3D3Dnewff([01],[1,900],{'logsig','logsig'},'trainrp','learngdm','mse'=
);
>
> > Space missing. I think you meant [ 0 1].
>
> > Nevertheless, you transposed L4 so you really need
>
> > repmat([0 1],900,1).
>
> > Better to use minmax(p).
>
> > [1 900] =3D3D=3D3D> 1 Hidden node and 900 output nodes.
>
> > Try [ H 900 ]
>
> > > net.trainParam.epochs=3D3D200;
> > > net.trainparam.goal=3D3D0;
> > > net.trainParam.show=3D3D25;
> > > net.trainParam.Gradient=3D3D0;
> > > net=3D3Dinit(net);
>
> > You probably can delete the above 5 commands.
> > See the defaults in
>
> > help newff
>
> > Also,
>
> > net =3D3D newff (...) results in automatic initialization.
>
> > > [net,tr]=3D3Dtrain(net,p,t);
> > > ??? Error using =3D3D=3D3D> network.train
> > > Inputs are incorrectly sized for network.
> > > Matrix must have 1 rows.
>
> > > If I change like:
>
> net=3D3Dnewff(minmax(p),[1,900],{'logsig','logsig'},'trainrp','learngdm',=
'm=3D> se')=3DAD;
> > > Warning: Divide by zero.
>
> > Can't help you with that one.
>
> > Hope that helps.
>
> > Greg
>
> Thank's for some hints. In fact I tried to get a result all
> the day but I failed. How do you think in what way the
> network would train better, if we have a matrix or an array
> as input
Array inputs will consist of 900 1-dimensional
input and target vectors as columns of p and t.
There for there is no correlation information
from neighboring pixels that can be used for
learning.
However, 30X30 input and target matrices contain
30 30-dimensional input and target vectors as
columns of p and t. The only correlation information
that can be used is restricted to columns.
If correlation information from neighboring pixels
is important, use the interior 28X28 array elements
as centers of a 3X3 subarrays resulting in
size(p) =3D [9 784]
size(t) =3D [1 784]
However, I don't quite understand what you are trying
to do.
Typically, design (training+validation) data is used
to create a model that will be used on nondesign
test data.
You have only one image. If you use that for design,
what will you use the model on? Do you have nondesign
data that you have not mentioned?
Greg Heath <heath@alumni.brown.edu> wrote in message
<2cdbace7-b2aa-450b-8237-656395c0ab73@l64g2000hse.googlegroups.com>...
> On Jul 5, 1:02=A0pm, "Olga Ghincul" <olea_...@yahoo.com>
wrote:
> > Greg Heath<he...@alumni.brown.edu> wrote in message
> >
> >
<2899e6ec-c83d-4eb3-9441-42dff1be2...@y21g2000hsf.googlegroups.com>...
> >
> >
> >
> > > On Jul 5, 9:04=3DA0am, "Olga Ghincul" <olea_...@yahoo.com>
> > wrote:
> > > > HI!
> > > > I have an image 30/30 pixels and I want to restore
it using
> > > > backpropogation. When I indicate the input of the
network as
> > > > a matrix:
> > > > K=3D3Dmat2gray(J);
> > > > everything goes well. But I want to try to have not
a matrix
> > > > input, but an array one.For example:
> > > > L=3D3Dreshape(K,1,900);
> > > > But in this case I have problems with network
architecture.
> > > > It creates in the first layer only one neuron and the
> > > > experiments have no sense in this case.
> > > > Can anybody tell me what's wrong here?
> > > > This is what I get:
> >
> > > > I4 =3D3D imread('Sb-4.jpg'); J4 =3D3D rgb2gray(I4);
K4 =3D3D
> > > > mat2gray(J4);
> >
> > > I'm not familiar with these functions. However, judging
> > > from their names it seems strange that mat2gray
> > > would follow rgb2gray.
> >
> > > > L4 =3D3D reshape(K4,1,900);
> > > > IE4 =3D3D imread('ESb4.jpg'); JE4 =3D3D
rgb2gray(IE4); KE4 =3D3D
> > > > mat2gray(JE4); LE4 =3D3D reshape(KE4,1,900);
> > > > p=3D3D[L4]';
> > > > t=3D3D[LE4]';
> >
> > > size(t) =3D3D size(p) =3D3D [ 900 1]
> >
> >
net=3D3Dnewff([01],[1,900],{'logsig','logsig'},'trainrp','learngdm','mse'=
> );
> >
> > > Space missing. I think you meant [ 0 1].
> >
> > > Nevertheless, you transposed L4 so you really need
> >
> > > repmat([0 1],900,1).
> >
> > > Better to use minmax(p).
> >
> > > [1 900] =3D3D=3D3D> 1 Hidden node and 900 output nodes.
> >
> > > Try [ H 900 ]
> >
> > > > net.trainParam.epochs=3D3D200;
> > > > net.trainparam.goal=3D3D0;
> > > > net.trainParam.show=3D3D25;
> > > > net.trainParam.Gradient=3D3D0;
> > > > net=3D3Dinit(net);
> >
> > > You probably can delete the above 5 commands.
> > > See the defaults in
> >
> > > help newff
> >
> > > Also,
> >
> > > net =3D3D newff (...) results in automatic initialization.
> >
> > > > [net,tr]=3D3Dtrain(net,p,t);
> > > > ??? Error using =3D3D=3D3D> network.train
> > > > Inputs are incorrectly sized for network.
> > > > Matrix must have 1 rows.
> >
> > > > If I change like:
> >
> >
net=3D3Dnewff(minmax(p),[1,900],{'logsig','logsig'},'trainrp','learngdm',=
> 'm=3D> se')=3DAD;
> > > > Warning: Divide by zero.
> >
> > > Can't help you with that one.
> >
> > > Hope that helps.
> >
> > > Greg
> >
> > Thank's for some hints. In fact I tried to get a result all
> > the day but I failed. How do you think in what way the
> > network would train better, if we have a matrix or an array
> > as input
>
> Array inputs will consist of 900 1-dimensional
> input and target vectors as columns of p and t.
> There for there is no correlation information
> from neighboring pixels that can be used for
> learning.
>
> However, 30X30 input and target matrices contain
> 30 30-dimensional input and target vectors as
> columns of p and t. The only correlation information
> that can be used is restricted to columns.
>
> If correlation information from neighboring pixels
> is important, use the interior 28X28 array elements
> as centers of a 3X3 subarrays resulting in
>
> size(p) =3D [9 784]
> size(t) =3D [1 784]
>
>
> However, I don't quite understand what you are trying
> to do.
>
> Typically, design (training+validation) data is used
> to create a model that will be used on nondesign
> test data.
>
> You have only one image. If you use that for design,
> what will you use the model on? Do you have nondesign
> data that you have not mentioned?
>
> Hope this helps.
>
> Greg
Thnak's for information you gave me. It helps me understand
more and more.
So,I have an image of a system block and a lot of defective
images with some wight/black spots on the same system
block.The image is 30X30 pixels. I used feed forward to
restore this image. I tried to give a different number of
training pairs, epochs, and the best architecture for this
problem was a 3 layer network with 30 neurons in each layer.
So I put the question what would happen, if I give the NN
not a matrix as an input, but an array:
reshape(KE4,1,900);
but I have problems in NN architecture, training and so one.
Am I doing something wrong?
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.