Having a problem training & Testing the Neural network
Show older comments
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);
Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!