Having a problem training & Testing the Neural network

3 visualizaciones (últimos 30 días)
Lameck Amugongo
Lameck Amugongo el 15 de Jun. de 2014
Comentada: Lameck Amugongo el 16 de Jun. de 2014
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);

Respuesta aceptada

Greg Heath
Greg Heath el 16 de Jun. de 2014
train takes 3 inputs, not 2.
help train
doc train
Hope this helps.
Thank you for formally accepting my answer
Greg

Más respuestas (0)

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by