Reducing 3D to 2D in Neural Network Training
    조회 수: 9 (최근 30일)
  
       이전 댓글 표시
    
I want to reduce 3-dimensional data to 2-dimensional in neural network training, not by using preprocessing, but by using a customized network in training, or a built-in network.Here is my customized layer, it doesn't achieve the result I want, I tried to reduce the dimension from 128x1xN to 128xN
classdef DownDimension < nnet.layer.Layer
    % 自定義降維層,將 (S*S*C) 降為 (S*C)
    methods
        function layer = DownDimension(name)
            % 層建構函式
            layer.Name = name;
            layer.Description = "Squeeze layer from (S*S*C) to (S*C)";
        end
        function Z = predict(layer, X)
            % 前向傳播操作
            % 假設 X 的尺寸為 (128, 1)
            % 顯示 X 的原始尺寸
            disp('Original size of X:');
            disp(size(X));
            % 如果需要轉換為 (128, 1, N)
            Z = reshape(X, [size(X,1), 1, size(X,2)]);
            % 顯示 Z 的新尺寸
            disp('New size of Z after reshaping:');
            disp(size(Z));
        end
    end
end
댓글 수: 3
답변 (1개)
  Umang Pandey
      
 2024년 11월 5일
        
      편집: Umang Pandey
      
 2024년 11월 5일
  
      Hi,
You can make use of the "squeeze" function to convert the matrix of dimension "128X1XN" to "128XN". The function simply removes the dimension of length 1. You can refer to the following MATLAB documentation for details on implementation and examples:
However, this function would remove the dimension of length 1, if you want to perform Dimensionality Reduction using some neural net which would preserve the data for some expected parameters while reducing dimensions, you can make use of some popular DR techniques like PCA (Principal Component Analysis), SOM (Self-Organizing Maps), etc. You can refer to the following MATLAB documentation for more information:
- Reduce dimensionality using PCA : https://www.mathworks.com/help/stats/reducedimensionalitytask.html
 - SOM : https://www.mathworks.com/help/deeplearning/ref/selforgmap.html
 
Best,
Umang
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!