Is it valid to enter a Non-Image input in Convolutional Neural Network toolbox?

8 ビュー (過去 30 日間)
Hello All, I was wondering wether it is possible to enter an input that is not an image in a CNN using the toolbox (2016b or later), i.e., I have a [:,:,3] matrix containing data of a signal through the time (every 20 ms), however, this data contains negative numbers, some numbers that are bigger than 255, and they are "double". Also, they are stored in a .mat file... so, I used the "imageDatastore" function to store the data:
imds = imageDatastore(location, 'FileExtensions', '.mat', 'IncludeSubfolders',1, ...
'LabelSource','foldernames');
but changing the "readFcn" for the next code:
function I = readFcn1(filename)
% Load data and get matrices from the structure
I = load(filename);
I = I.signaldata;
I send it to the "trainNetwork" function and "works", however, i do not know if internally it changes data of negative numbers, changes form double to uint16, or it trains the network with the original ones. Or there is another way to use a Non-image input for a CNN.
Thanks in advance ;)
  3 件のコメント
Javier Pinzón
Javier Pinzón 2017 年 12 月 14 日
編集済み: Javier Pinzón 2017 年 12 月 14 日
You need to create a function with this code:
function I = readFcn1(filename)
% Load data and get matrices from the structure
I = load(filename);
I = I.signaldata;
Where "signaldata" is the name that have your variable when you load it from a file.
And when you call the data, you type this:
imds = imageDatastore(location, 'FileExtensions', '.mat', 'IncludeSubfolders',1, ...
'LabelSource','foldernames');
countEachLabel(imds)
trainingDS = imds;
% Convert labels to categoricals
trainingDS.Labels = categorical(trainingDS.Labels);
trainingDS.ReadFcn = @readFcn1;
So, the training dataset call the Function each time.
Hope it helps
SRUTHY SKARIA
SRUTHY SKARIA 2018 年 2 月 21 日
Hi, I have a similar problem. I tried use the code but my code doesn't read the function, so I am unable to get the cell array from the mat file. Also the function should end with an 'end' rigt? Also with function I = readFcn1(filename), by filename it meant the entire path with the mat file right? Would you be able to give me advice one this. Thank you

サインインしてコメントする。

採用された回答

Javier Pinzón
Javier Pinzón 2017 年 7 月 13 日
I will answer my own question looking at some test that I have made:
As far as I check, it is possible to use as the CNN input a matrix consisting in purelly negative number, using .mat files as database elements, and it works pretty well. However, when use it, it is highly recommended not to use the "ReLU Layer", due to the fact that if it is used, most of the Matrix will become 0.
I hope in any update soon Matlab implement another kind of activation layer, such as PReLU or another that dont send al the negative matrix to 0, and also build a dtabase not using only the "imagedatastore" function =).
Hope it helps to any body want to use the CNN toolbox for processing not images but anything else.
  2 件のコメント
sruthy shankar
sruthy shankar 2018 年 2 月 6 日
hello sir,Iam having a similar problem ..can u help me to solve it? iam working on CNN,but my input datas are not images but some numeric datas which are stored in an excel sheet,i have to split the excel sheet data to two sets one for training and other for testing.and also in each excel sheet each row is my input to the network,how can i provide such a data to a CNN?
Javier Pinzón
Javier Pinzón 2018 年 2 月 22 日
Hello Everybody:
To the solution of the problem presented by Sruthy, you can follow this topic:
Best regards

サインインしてコメントする。

その他の回答 (1 件)

Zachary David
Zachary David 2017 年 9 月 14 日
Hi Javier,
I've been experimenting with a similar case. A seemingly decent solution is to pre-process your values by mapping them to a specific range. You can use the procedures described in Matlab's mapminmax to do this for you.
Or (preferred) if you want to do it manually you can do:
yMapped = (ymax-ymin).*(x-xmin)./(xmax-xmin) + ymin;
where ymin and ymax are your target range, and xmin and xmax are the minimum and maximum values of your data.
The benefit of using this technique is that it preserves the shape of the distributions for each of your variables.
Enjoy

Community Treasure Hunt

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

Start Hunting!

Translated by