フィルターのクリア

How can I apply PCA on thousand of images to reduce the dimension of the data?

4 ビュー (過去 30 日間)
MUHAMMAD ALKHUDAYDI
MUHAMMAD ALKHUDAYDI 2019 年 8 月 29 日
コメント済み: Subhadeep Koley 2019 年 9 月 6 日
Hi,
I applied a simple CNN on dataset of 1000 images and the code works fine. However, I want to apply PCA on both training and testing set in order to reduce reduce its dimensionality (features selection) the code is below. Many thanks.
close all
clear all
clc
%% Load image data
imds = imageDatastore('the path of images folder',...
'IncludeSubfolders',true,'LabelSource','foldernames')
tbl = countEachLabel(imds)
%% Divide the data into 70% training data and 30% validation data
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7,'randomized');
%% Specify training options.
options = trainingOptions('sgdm', ...
'MiniBatchSize',10, ...
'MaxEpochs',3, ...
'Shuffle','every-epoch', ...
'InitialLearnRate',1e-4, ...
'ValidationData',imdsValidation, ...
'ValidationFrequency',6, ...
'Verbose',false, ...
'Plots','training-progress', ...
'ExecutionEnvironment','gpu');
%% Layers for simple CNN.
layers_1 = [
imageInputLayer([512 512 1])
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
%% train the network
netTransfer = trainNetwork(imdsTrain,layers_1,options);

回答 (0 件)

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by