Reducing 3D to 2D in Neural Network Training
39 次查看(过去 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,4:19
编辑:Umang Pandey
2024-11-5,4:19
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 中查找有关 Quantization, Projection, and Pruning 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!