Using word embedding layer and convolutional layer

Hello everyone. I'm new to use MATLAB. i had to implement a neural network described in keras in MATLAB for a project. I have to use various layer such as wordembedding layer and convolutional layer. i don't understand if the wordembedding layer of matlab equals the embedding layer of keras. As input i have sequence of 200 amino acids. Using deep network designer I built this net but it keep giving me error in the convolutional layer because there is a mismatch.
lgraph = layerGraph();
tempLayers = [
sequenceInputLayer(1,"Name","sequence")
wordEmbeddingLayer(128,3,"Name","word-embedding")
sequenceFoldingLayer("Name","seqfold")];
reluLayer
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
convolution2dLayer([1 16],64,"Name","conv","BiasInitializer","narrow-normal","Padding","same","Stride",1)
batchNormalizationLayer("Name","batchnorm")
reluLayer("Name","relu")
maxPooling2dLayer([5 1],"Name","maxpool","Padding","same")
];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
sequenceUnfoldingLayer("Name","sequnfold")
flattenLayer("Name","flatten")
lstmLayer(100,"Name","lstm","OutputMode","last")
dropoutLayer(0.1,"Name","dropout")
%fullyConnectedLayer(numClasses)
sigmoidLayer("Name","sigmoid")
softmaxLayer("Name","softmax")
classificationLayer("Name","classoutput")];
lgraph = addLayers(lgraph,tempLayers);
lgraph = connectLayers(lgraph,"seqfold/out","conv");
lgraph = connectLayers(lgraph,"seqfold/miniBatchSize","sequnfold/miniBatchSize");
lgraph = connectLayers(lgraph,"maxpool","sequnfold/in");

1 Kommentar

Hi
Can you share the Keras model which you are trying to implement in MATLAB?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2021a

Gefragt:

am 26 Aug. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by