Having a problem training & Testing the Neural network

I have a group of images in a folder and i would like to train the neural network using the features extracted using the gray co-occurrence matrix.
function neuralNetwork(img)
%NN Summary of this function goes here
% Detailed explanation goes here
files = dir('*.png');
hist = [];
net = lvqnet(10);
for n = 1 : length(files)
file = imread(files(n).name);
[rows columns numberOfColorChannels] = size(file);
%%Check if the im loaded is a grayscale image
if numberOfColorChannels > 1
%%Coverting to grayscale & get the co-occurrence matrix
F = graycomatrix(rgb2gray(file));
else
F= graycomatrix(file); %get co-occurrence matrix
end
hist = [hist, imhist(F)]; %#ok
end
% Create a Self-Organizing Map
dimension1 = 10;
dimension2 = 10;
net = selforgmap([dimension1 dimension2]);
% Train the Network
[net,tr] = train(net,hist); % The error is here
% Test the Network
outputs = net(hist);
% View the Network
view(net)
I am getting the following error:
>> neuralNetwork('C:\Users\Lameck\Documents\MATLAB\Project\TrainingSet\0001.png');
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> learnsomb>apply at 122
a2 = neighborhood * a + a;
Error in ==> trainbu>train_network at 206
[dw,IWLS{i,j}] = fcn.apply(net.IW{i,j}, ...
Error in ==> trainbu at 103
[net,tr] = train_network(net,tr,data,fcns,param);
Error in ==> network.train at 107
[net,tr] = feval(net.trainFcn,net,X,T,Xi,Ai,EW,net.trainParam);
Error in ==> neuralNetwork at 26
som = train(som, hist);

 採用された回答

Greg Heath
Greg Heath 2014 年 6 月 16 日

1 投票

train takes 3 inputs, not 2.
help train
doc train
Hope this helps.
Thank you for formally accepting my answer
Greg

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by