Asked by Jaewon Kim
on 12 Jul 2018

Hello

I have 7000 data that it is CSV file and 1-D (1*125)

the value in cells over 0 under 1.

it is divided into 17 categories, also divided into Training data(90%) and Test data(10%), randomly.

I want to make CNN net using this data.

And my code is like below

% Import data HSdata = imageDatastore('C:\Users\lovel\OneDrive\Research\Deep learning stuff\Deep learning normalization\Seperation','Readfcn',@readDatastoreCSV,'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.csv')

% labeling the names rocknames = HSdata.Labels

% Dividing into Training Data and Testing Data [HSdataTraining,HSdataTesting] = splitEachLabel(HSdata,0.9,'randomized')

%layers layers=[ imageInputLayer([1 125]); convolution2dLayer([1 3],64,'Stride',1,'Padding',1); convolution2dLayer([1 3],64,'Stride',1,'Padding',1); reluLayer(); maxPooling2dLayer([1 2],'Stride',2); convolution2dLayer([1 3],128,'Stride',1,'Padding',1); convolution2dLayer([1 3],128,'Stride',1,'Padding',1); reluLayer(); maxPooling2dLayer([1 2],'Stride',2); convolution2dLayer([1 3],256,'Stride',1,'Padding',1); convolution2dLayer([1 3],256,'Stride',1,'Padding',1); reluLayer(); maxPooling2dLayer([1 2],'Stride',2); fullyConnectedLayer(400); fullyConnectedLayer(400); fullyConnectedLayer(17); softmaxLayer(); classificationLayer(); ];

%option options = trainingOptions('sgdm' ,'ExecutionEnvironment','GPU')

[HSdatanet,info] = trainNetwork(HSdataTraining,layers,options);

And I tested that net using Test data(10% of whole data).

The predicted data is just one result.

I really want to know the problem.

Opportunities for recent engineering grads.

Apply Today
## 9 Comments

## Von Duesenberg (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_588532

It's hard to tell from your description. What arguments do you provide to trainNetwork? Are you working with datastores? Your whole code might be helpful.

## Jaewon Kim (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_588823

Thank you for your Comments

I edit it!

## Von Duesenberg (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_588825

Could you add the line corresponding to the prediction on the test data?

## Jaewon Kim (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_588881

Thank you for your reply.

and the original data (line) is like below.

I used this data, but there is the same problem. So I normalized that data to be over 0 and under 1. Modified data(line) is like below

And there are about 7000 data like this line. And 6300 data will be training data and 700 data will be used for testing.

p.s The biggest value of the 7000 data is 8679. And I used this value for modifying my data to make the value over 0 under 1.

## Von Duesenberg (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_588895

Ok, I have two questions then. How does the training go? Maybe you could set the Plots option to 'training-progress' to see exactly what happens, and then is this what you do for the test?:

## Jaewon Kim (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_589107

Dear Von Duesenberg

First, Thank you for comments.

1. I try to use the Plots option to 'training-process' to see what happens.

And the accuracy is almost 10% at every epoch.but there are very very small differences at every Epoch (about +-2%)

the Loss is keeping high around 3 at every epoch.

2. I check the scores using upper code.

Every scores is same value. even though the labels is not same and they are different data.

## Von Duesenberg (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_589267

There is clearly something wrong but I can't put my finger on it, sorry. The best I can do is to suggest you have a look at this thread and the answer by Mathworker Joss Knight, whose suggested workflow I managed to replicate a couple of weeks ago. So, I have to say, it

doeswork, and maybe if you adapt his workflow to your own, you might be able to find out what went wrong in the first place. Good luck.## Joss Knight (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_589399

"The predicted data is just one result" doesn't make much sense. If you are calling

predictorclassifywith 700 observations then you must get 700 results. Let's take a look at exactly what is in your test data, and exactly what your code is that you are using to predict on your test data.## Jaewon Kim (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/410017-how-can-i-avoid-one-results-in-cnn#comment_589867

Dear Knight and Duesenberg.

I solved this problem. the problem was the maxpooling. I have to use the stride of maxpooling is 1D (1*2 or 1*3)

thanks for your attention!

And I want to say that the predicted data was the same results, not "The predicted data is just one result". it means there are 700 test data, then there was also 700 scores of each data. Sorry for making you confused.

Sign in to comment.