how to create Time distributed layer

조회 수: 4 (최근 30일)
angeline yap
angeline yap 2022년 2월 12일
답변: Purvaja 2025년 2월 19일
Hi, i try to create a time distributed layer for my lstm encoder decoder, which i make use of timedelaynet. But whenever i make use this, i get the error because it is the network instead of layer. May i know if there is anywhere to create time distributed layer. Thank you
layers=[...
sequenceInputLayer(numInFeatures)
lstmLayer(numEnUnits,"OutputMode","last")
repeatVectorLayer(30)
lstmLayer(numDeUnits)
timedelaynet(30,numDenseUnits)
timedelaynet(30,numOutFeatures)
regressionLayer];
-----------------------------------------------------------------------------------------
%% this is the error that is gotten
Cannot convert from 'network' to 'nnet.cnn.layer.SequenceInputLayer'.

답변 (1개)

Purvaja
Purvaja 2025년 2월 19일
I understand that you want to create a “Time distributed Layer” in your implementation of network. As a matter of fact, the timedelaynet” function builds a new neural network and hence cannot be used as a layer in “Layer” function in MATLAB.
The following MATLAB Community question touches upon implementation of “Time Distributed” layer in MATLAB:
In answer it was mentioned that we can use “sequenceFoldingLayer” and “sequenceUnoldingLayerto implement “Time Distributed” layers.
By using the same we can incorporate “Time Distributed” layers by replacingtimedelaynet(30,numDenseUnits)” with this:
sequenceFoldingLayer()
fullyConnectedLayer(numDenseUnits)
sequenceUnfoldingLayer()
But if you want to incorporate user-defined time delay, try making a custom timedelay” layer function for such architecture and use it in layers.
Or for more clarification or adjusting it according to your input and output requirements, the following documentation links would be helpful:
  1. For "sequenceFoldingLayer" function: https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.sequencefoldinglayer.html
  2. For "sequenceUnfoldingLayer" function: https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.sequenceunfoldinglayer.html
You can also try this command in your MATLAB command window for specific release documentation:
  • For "sequenceUnoldingLayer" function:
web(fullfile(docroot,'deeplearning/ref/nnet.cnn.layer.sequenceunfoldinglayer.html'))
  • For "sequenceFoldingLayer" function:
web(fullfile(docroot,'deeplearning/ref/nnet.cnn.layer.sequencefoldinglayer.html'))
Hope this helps you!

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by