在matlab中使用前馈反向传播网络时出错

时间:2015-04-06 09:07:54

标签: matlab image-processing neural-network

在运行给定代码时,我收到错误

  

内存不足。键入HELP MEMORY以获取选项。

前馈反向传播网络用于训练和测试。我使用14个图像进行训练,23个进行测试。所需的输出分为7个图像类。

clc
l_code=1000;
P1=zeros(l_code,14);
T = [1 0 0 0 0 0 0 1 0 0 0 0 0 0 
     0 1 0 0 0 0 0 0 1 0 0 0 0 0 
     0 0 1 0 0 0 0 0 0 1 0 0 0 0 
     0 0 0 1 0 0 0 0 0 0 1 0 0 0 
     0 0 0 0 1 0 0 0 0 0 0 1 0 0 
     0 0 0 0 0 1 0 0 0 0 0 0 1 0 
     0 0 0 0 0 0 1 0 0 0 0 0 0 1];

fid1= fopen('C:\Source Code\files\output1.txt','w+');

%---------------------------Executing Files---------------------------
for i=1:14
    [c1]= HGR(['C:\Source Code\images\training\hand' int2str((i)) '.jpg']);
    %c=imresize(c,[10 10]);
    %c1=reshape(c,100,1);
    %c1 = transpose(c1);
    P1(:,i)=c1(:);

    fprintf(fid1,'Hand (%d)\r\n',i);
end;
fclose(fid1);

%------------------------Neural Network-------------------------
net = newff(minmax(P1),[l_code 7],{'tansig', 'purelin'});  
net.trainParam.epochs = 500;
net.trainParam.show=NaN;
net.trainParam.goal=0;
%net.trainParam.min_grad=1e-6;
net = train(net,P1,T,'useGPU','yes');

nn_train = fopen('C:\Source Code\files\NN Training.txt','w+');

for g=1:23
[f1]= HGR(['C:\Source Code\images\final\hand (' int2str((g)) ').jpg']);
A = transpose(f1);
A = double(A);
Y = sim(net,A);

maximum = max(Y);

for p = 1:7
    if(Y(p) == maximum)
    if (p == 1)
        fprintf(fid1,'hand(%d) : Class A\r\n',g);
    elseif (p == 2)
            fprintf(fid1,'hand(%d) : Class B\r\n',g);
    elseif (p == 3)
            fprintf(fid1,'hand(%d) : Class C\r\n',g);
    elseif (p == 4)
            fprintf(fid1,'hand(%d) : Class D\r\n',g);
    elseif (p == 5)
            fprintf(fid1,'hand(%d) : Class E\r\n',g);
    elseif (p == 6)
            fprintf(fid1,'hand(%d) : Class F',g);
    elseif (p == 7)
            fprintf(fid1,'hand(%d) : Class G\r\n',g);
    end;
    end;
end;
end;

错误

的屏幕截图

enter image description here

我在这里缺少什么?

0 个答案:

没有答案