Effacer les filtres
Effacer les filtres

How to convert the format of data from sequences to matrices when designing deep learning networks?

12 vues (au cours des 30 derniers jours)
Hello,
After importing the network into DeepNetworkDesigner for analysis, I encountered the following problem: after being processed by selfattentionLayer, the data size format is 577 (S) x 577 (C) x 1 (B).
I want to convert it to a format similar to imageInputLayer, _ (S) x_ (S) x_ (C) x_ (B). How can I use MATLAB to implement it?
The code for the network is as follows:
patchSize = 16;
embeddingOutputSize = 768;
layer = patchEmbeddingLayer(patchSize,embeddingOutputSize)
net = dlnetwork;
inputSize = [384 384 3];
maxPosition = (inputSize(1)/patchSize)^2 + 1;
numHeads = 4;
numKeyChannels = 4*embeddingOutputSize;
numClasses = 1000;
layers = [
imageInputLayer(inputSize)
patchEmbeddingLayer(patchSize,embeddingOutputSize,Name="patch-emb")
embeddingConcatenationLayer(Name="emb-cat")
positionEmbeddingLayer(embeddingOutputSize,maxPosition,Name="pos-emb");
additionLayer(2,Name="add")
selfAttentionLayer(numHeads,numKeyChannels,AttentionMask="causal",OutputSize=maxPosition)
fullyConnectedLayer(numClasses)
softmaxLayer];
net = addLayers(net,layers);
net = connectLayers(net,"emb-cat","add/in2");
  4 commentaires
Cris LaPierre
Cris LaPierre le 1 Juin 2024
Can you share a sample data set? That will make it easier to help.
Tian,HCong
Tian,HCong le 2 Juin 2024
Thank you very much for your prompt reply.
This dataset comes from the folder in Matlab and is commonly used by me when testing simple deep learning networks.

Connectez-vous pour commenter.

Réponses (0)

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by