Borrar filtros
Borrar filtros

Can we connect the fullyconnected layer of the Vgg19 pretrained model with the TCN block so that the Vgg19 and TCN can be combined? I have 2 Errors and I need to be solved

2 visualizaciones (últimos 30 días)
net = vgg19;
lgraphUpdated = layerGraph(net);
lgraphUpdated = removeLayers(lgraphUpdated,'output');
lgraphUpdated = removeLayers(lgraphUpdated,'prob');
% Replace the fullyconnected with 1000 class with fullyconnected with 2
% clases
newFCLayer = fullyConnectedLayer(numClasses,'Name','new_fc','WeightLearnRateFactor',10,'BiasLearnRateFactor',10);
lgraphUpdated = replaceLayer(lgraphUpdated,'fc8',newFCLayer);
% add a flatten layer after the fullyconnected layer
newadd = flattenLayer('Name','f1');
lgraphUpdated = addLayers(lgraphUpdated,newadd);
% TCN Model % start the TCN model with the flatten layer of the Vgg19
% then pass the output of the flatten layer to 1D convolution dilated
% casual layer
numFeatures = 2;
numFilters = 64;
filterSize = 5;
dropoutFactor = 0.005;
numBlocks = 4;
lgraph = lgraphUpdated.Layers;
lgraph = layerGraph(lgraph);
outputName = 'f1';
for i = 1:numBlocks
dilationFactor = 2^(i-1);
layers = [
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal",Name="conv11_"+i)
layerNormalizationLayer
dropoutLayer(dropoutFactor)
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal")
layerNormalizationLayer
reluLayer
dropoutLayer(dropoutFactor)
additionLayer(2,Name="add_"+i)];
% Add and connect layers.
lgraph = addLayers(lgraph,layers);
lgraph = connectLayers(lgraph,outputName,"conv11_"+i);
% Skip connection.
if i == 1
% Include convolution in first skip connection.
layer = convolution1dLayer(1,numFilters,Name="convSkip");
lgraph = addLayers(lgraph,layer);
lgraph = connectLayers(lgraph,outputName,"convSkip");
lgraph = connectLayers(lgraph,"convSkip","add_" + i + "/in2");
else
lgraph = connectLayers(lgraph,outputName,"add_" + i + "/in2");
end
% Update layer output name.
outputName = "add_" + i;
end
layers = [
fullyConnectedLayer(numClasses,Name="fc")
softmaxLayer
classificationLayer];
lgraph = addLayers(lgraph,layers);
lgraph = connectLayers(lgraph,outputName,"fc");
analyzeNetwork(lgraph);
x = 0;

Respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by