Neural Network training and Testing (classification)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am new to machine learning. Here is the problem description: I have 10,000 inputs, 1,000 test, and (only) ONE target image. Each input, test, and target is the identical grayscale image of 256X256 resolution. In the input there are 10,000 corresponding rotation (angle) and 10,000 shift values. So the 10,000 input images are shifter and rotated. The target is the same image (as inputs) with no rotation and no shift (basically, zero shift and zero rotation). The 1,000 test images are shifted and rotated but obviously with no information for shift and for rotation. Since my train and test data are 3-dimensional, I have "columnized" each image input, test, and target as 65536X1. Hence, my input is 65536X10000; test is 65536X1000; and target is 65536X1.
I get the error, "Inputs and targets have different numbers of samples." which obviously is true taken what it is. My question is whether I could have my number of samples to be different in input vs. target.
If so, what "flavor" of function calls do I need.
BTW, my patchy solution (i have not tried it yet) is to replicate the one target 10000 times so I have a matching input and target but somehow it doesn't seem to be an efficient way of doing it.
The error occurs in line: "net = train(net,train_data_2d,ImTruth_1d);". Below is the code. Thanks.
clear all; close all; clc; % train_data = load('FrameStack.mat'); test_data = load('FrameTest.mat'); % N_train = 10000; N_test = 1000; N_image = 256; % train_data_2d = zeros(N_image*N_image,N_train); test_data_2d = zeros(N_image*N_image,N_test); % % Convert the input, test, and target from 3-d to 2-d matrices. % for ii = 1:N_train temp = []; temp = train_data.Images(:,:,ii); temp = temp(:); %train_data_2d = horzcat(train_data_2d,reshape(train_data.Images(:,:,i),[],1)); train_data_2d(:,ii) = temp; end % for iii = 1:N_test temp = []; temp = test_data.Images(:,:,iii); temp = temp(:); %train_data_2d = horzcat(train_data_2d,reshape(train_data.Images(:,:,i),[],1)); test_data_2d(:,iii) = temp; end % temp = []; temp = train_data.ImTruth(:); ImTruth_1d = temp(:); % % % net = feedforwardnet(20); net = train(net,train_data_2d,ImTruth_1d); % outputs = net(test_data_2d); errors = gsubtract(test_data_2d,outputs); performance = perform(net,test_data_2d,outputs) %
0 commentaires
Réponses (1)
Mary Abbott
le 30 Oct 2017
Hello,
The target for a neural network is the desired output for a given input. When training the network, you are specifying that for each column in the input matrix, the desired output is the corresponding column in the target matrix. Therefore, the target matrix should have the same amount of columns as the input matrix. This can be done using the solution you mentioned in your post, duplicating the one target output into a 65536 x 10000 matrix.
The following link gives a simpler example of how data is prepared for training a neural network:
https://www.mathworks.com/help/nnet/examples/crab-classification.html#d119e3584
0 commentaires
Voir également
Catégories
En savoir plus sur Pattern Recognition and Classification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!