Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

A newbie question about a code error....

thp_grthp_gr Member Posts: 2
Hello! I am totally new in matlab. I'm trying to run a script about training a neural network in the recognition of "1" and "0" through images. I import a file in my workspace with the name "data" which contains all images.

[b]Script is the following:[/b]
[italic]load ('usps_all.mat'); %load images
data = double (data);
data = data (:,:,[1,10]);

%2000 images for network's training, 0-1000 are "1",1001-2000 are "0"
image1_train = data(:,1:1000,1);
image0_train = data(:,1:1000,2);

%200 images for confirmation, 0-100 are "1",101-200 are "0"
image1_test = data(:,1001:end,1);
image0_test = data(:,1001:end,2);

%Creation of network's exit. First 1000 digits are "1",
digit(1:1000)=[1];
%rest 1000 are "0"
digit(1001:2000)=[0];

% table with all training images
imtrain = cat(2,image1_train, image0_train);
% table with all confirmation images
imtest = cat(2,image1_test, image0_test);

%min and max value of table "imtrain"
range (1:256,1)=[0];
range (1:256,2)=[255];

%Neural network with 2 middleway levels,16 & 5 nodes
net = newff(range,[16 5 1],{'logsig' 'logsig' 'logsig'},'trainlm');
%Parameters for the network training
net.trainParam.epochs = 30;
net.trainParam.goal = 0.0005;


[net,tr] = train(net, double(imtrain), digit);

%Simulation with confirmation data
s = sim(net,imtest);

%Normally it should have "0" in first 100 positions and "1" the rest
s=round(s);
[/italic]
----------------------------------------------------------------------

In this part of the script:
[italic]net = newff(range,[16 5 1],{'logsig' 'logsig' 'logsig'},'trainlm'); [/italic]
I get the following errors:

Warning: NEWFF used in an obsolete way.
> In obs_use at 18
In newff>create_network at 127
In newff at 102
See help for NEWFF to update calls to the new argument list.

At compilation, "data" was determined to be a variable and this
variable is uninitialized. "data" is also a function name and previous versions of MATLAB would have called the function.
However, MATLAB 7 forbids the use of the same name in the same
context as both a function and a variable.

Error in nnerr.obs_use (line 26)
data = double (data);

Error in newff>create_network (line 127)
nnerr.obs_use(mfilename,['See help for ' upper(mfilename) ' to update calls to the new argument list.']);

Error in newff (line 102)
-------------------------------------------------------

I run the script successfully once, but the second time I tried i had the previous error. Does anyone knows what I did wrong?

Thanks in advance!
Sign In or Register to comment.