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 Center および File ExchangeStatistics 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