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 Comment

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

Sign in to comment.

Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Products

Release

R2021a

Asked:

on 26 Aug 2021

Commented:

on 15 Sep 2021

Community Treasure Hunt

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

Start Hunting!