필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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 CenterFile Exchange에서 Dimensionality 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