Thread Subject: NNz won't take a 160-by-120 binary image??

Subject: NNz won't take a 160-by-120 binary image??

From: chris Austin

Date: 7 Feb, 2010 11:08:03

Message: 1 of 6

Here i am trying to parse a 160-by-120 binary image size to the neural network but it throwing exceptions i don't understand. can someone help me out on how to put an image to the NNs? i also tried to flatten the image before passing it in but same error.

input = image; %160-by-120 binary image size(basically just black and white)
target = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];

>> net = newfit(input,target,10);

??? Error using ==> minmax at 43
Argument has illegal type.

Error in ==> network.subsasgn>setInputExampleInput at 909
range = minmax(p);

Error in ==> network.subsasgn at 96
        [net,err] = setInputExampleInput(net,i,exampleInput);

Error in ==> newff>new_5p1 at 144
net.inputs{1}.exampleInput = p;

Error in ==> newff at 89
  net = new_5p1(varargin{:});

Error in ==> newfit at 67
net = newff(varargin{:});

Subject: NNz won't take a 160-by-120 binary image??

From: us

Date: 7 Feb, 2010 20:09:04

Message: 2 of 6

"chris Austin" <christianaugustine@yahoo.com> wrote in message <hkm6uj$f0l$1@fred.mathworks.com>...
> Here i am trying to parse a 160-by-120 binary image size to the neural network but it throwing exceptions i don't understand. can someone help me out on how to put an image to the NNs? i also tried to flatten the image before passing it in but same error.
>
> input = image; %160-by-120 binary image size(basically just black and white)
> target = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];

a hint:
- 1st: do NOT name a variable INPUT as this is a built-in ML function...
- 2nd: try

     img=double(image);
% ...

us

Subject: NNz won't take a 160-by-120 binary image??

From: chris Austin

Date: 8 Feb, 2010 21:39:05

Message: 3 of 6

"us " <us@neurol.unizh.ch> wrote in message <hkn6l0$51v$1@fred.mathworks.com>...
> "chris Austin" <christianaugustine@yahoo.com> wrote in message <hkm6uj$f0l$1@fred.mathworks.com>...
> > Here i am trying to parse a 160-by-120 binary image size to the neural network but it throwing exceptions i don't understand. can someone help me out on how to put an image to the NNs? i also tried to flatten the image before passing it in but same error.
> >
> > input = image; %160-by-120 binary image size(basically just black and white)
> > target = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];
>
> a hint:
> - 1st: do NOT name a variable INPUT as this is a built-in ML function...
> - 2nd: try
>
> img=double(image);
> % ...
>
> us

thanks very much for your reply.

I have followed you instructions but i got a different set of errors this time.
here is the code I ran......
img=imread('1000001.png');
target1 = [0,0,0,0,0,1,0,0,0,0,0];
ims = double(img);
net = newfit(ims,target1,10);



and the error i get is..........

Error in ==> fixunknowns>new_process at 87
unknown_rows = ~isfinite(sum(x,2))';

Error in ==> boiler_process at 136
[out1,out2] = new_process(in1,in2); y =[]; % MATLAB BUG if [out1,y] =...

Error in ==> fixunknowns at 65
boiler_process

Error in ==> network.subsasgn>calcProcessSettings at 1087
  [p2,ps] = feval(ithFcn,p,paramValues{:});

Error in ==> network.subsasgn>setInputProcessFcns at 961
[processSettings,p] = calcProcessSettings(p,processFcns,processParams);

Error in ==> network.subsasgn at 106
        [net,err] = setInputProcessFcns(net,i,processFcns);

Error in ==> newff>new_5p1 at 145
net.inputs{1}.processFcns = ipf;

Error in ==> newff at 89
  net = new_5p1(varargin{:});

Error in ==> newfit at 67
net = newff(varargin{:});

Subject: NNz won't take a 160-by-120 binary image??

From: us

Date: 8 Feb, 2010 21:52:04

Message: 4 of 6

"chris Austin"
> and the error i get is..........
>
> Error in ==> fixunknowns>new_process at 87
> unknown_rows = ~isfinite(sum(x,2))';

you show the error stack - but NOT the actual error(!)...
anyhow, you could do this

% at the command prompt, type
     dbstop if error;
% run your code, it will error and stop at the offending line...
% now, check your vars...

us

Subject: NNz won't take a 160-by-120 binary image??

From: chris Austin

Date: 8 Feb, 2010 22:04:04

Message: 5 of 6

"us " <us@neurol.unizh.ch> wrote in message <hkq124$hag$1@fred.mathworks.com>...
> "chris Austin"
> > and the error i get is..........
> >
> > Error in ==> fixunknowns>new_process at 87
> > unknown_rows = ~isfinite(sum(x,2))';
>
> you show the error stack - but NOT the actual error(!)...
> anyhow, you could do this
>
> % at the command prompt, type
> dbstop if error;
> % run your code, it will error and stop at the offending line...
> % now, check your vars...
>
> us

i appreciate the quick response. I tried flattening the image and it succeeded. however, rather than putting just one image to the net, i want to put 300 different images. is this possible? if yes how can i possibly achive this? Thank you so much.

Subject: How??

From: chris Austin

Date: 9 Feb, 2010 15:24:04

Message: 6 of 6

Hi guys,
I am a newbie trying to get my head round matlab for my project. Here i am trying to train a feedforward Neural net that takes a binary image, i set the target as stated below but when i call the train function it displays the error message..

??? Error using ==> network.train at 146
Targets are incorrectly sized for network.
Matrix must have 1 columns.

here is my tiny implimentation. please kindly tell me what i am doing wrong or what i should do.

img=imread('1000001.png'); %160-by-120 binary image size(basically just black and white)
target1 = [0 0 0 0 0 1 0 0 0 0 0];
ims = double(img);
[r, c] = size(img);

im = reshape(ims, r*c, 1);

nets = newff(im,target1, 10);

net = train(nets, im, target1);

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
dbstop us 8 Feb, 2010 16:54:06
double us 7 Feb, 2010 15:14:06
code us 7 Feb, 2010 15:14:06
image processing chris Austin 7 Feb, 2010 06:09:04
neural networks chris Austin 7 Feb, 2010 06:09:04
rssFeed for this Thread

Contact us at files@mathworks.com