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");

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品

版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by