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 ==> mtimesInner 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 26som = train(som, hist);
Best Answer