- The R2017b Prerelease adds functionality to create neural networks with custom layers; see the documentation page "Create Custom Layer with Learnable Parameters" (only available after you install the prerelease!). You could create a custom layer after the image input layer that scales the data.
- You can pre-process your images to scale the color data, save the scaled images, and then pass the modified images to your neural network.
Why there the normalization of the imageIputLayer is Zero-Center, what should I do when I want to scale the image to [0,1] before training?
6 ビュー (過去 30 日間)
古いコメントを表示
as the document said:https://cn.mathworks.com/help/nnet/examples/create-simple-deep-learning-network-for-classification.html
digitDatasetPath = fullfile(matlabroot,'toolbox','nnet','nndemos', ...
'nndatasets','DigitDataset');
digitData = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
trainingNumFiles = 750;
rng(1) % For reproducibility
[trainDigitData,testDigitData] = splitEachLabel(digitData, ...
trainingNumFiles,'randomize');
layers = [imageInputLayer([28 28 1])
convolution2dLayer(5,20)
reluLayer
maxPooling2dLayer(2,'Stride',2)
fullyConnectedLayer(10)
softmaxLayer
classificationLayer()];
options = trainingOptions('sgdm','MaxEpochs',15, ...
'InitialLearnRate',0.0001);
convnet = trainNetwork(trainDigitData,layers,options);
the data format of the image is 0¬255, but most cnn they trains with data [0,1] so before training, they should normalize the data by data/255.
but in this demo code, the data input of this function is only the index of the image. so I can't do anything to pre-processing the image before.
convnet = trainNetwork(trainDigitData,layers,options);
the only thing I can do to normalize the training data is in the layer
layers = [imageInputLayer([28 28 1])
but the only normalization option this Layer class can support is zero-center (data-mean of data).
what should I do when i want to normalize the input? Or there is no need for a cnn to normalize the training data?
0 件のコメント
採用された回答
Scott Weidenkopf
2017 年 7 月 31 日
There is not any built-in MATLAB functionality to normalize the data in the manner you describe. A few approaches do exist however:
Whether or not this normalization or scaling is strictly necessary, however, depends on your use case.
2 件のコメント
Mona
2017 年 10 月 31 日
Hi. I was wondering the same thing. How to create a custom data pr-processing layer? Say that I want to manually take a random crop of every image in each mini-batch. How do I define the layer?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で 图像深度学习 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!