Vector to sequence generative machine learning model?

조회 수: 10 (최근 30일)
Giacomo Notaro
Giacomo Notaro 2020년 3월 12일
답변: sanidhyak 2025년 7월 2일
Hi all,
I'm looking for a vector to sequence machine learning model, which is trained with initial condition vectors and output sequences.
So that in the end it generates a sequence corresponding to a test initial condition vector.
Is there any model capable of doing this?

답변 (1개)

sanidhyak
sanidhyak 2025년 7월 2일
I understand that you are looking to train a model that takes an initial condition vector as input and outputs a corresponding sequence. This is a classic case of a "sequence generation" problem, which can effectively be modeled using "LSTM-based neural networks" provided by MATLAB’s Deep Learning Toolbox. Do note that there is no "one-line" or "prebuilt function" for "vector-to-sequence" generation.
Kindly refer to the following sample code to build such a model:
% Example input: Initial condition vectors
XTrain = {rand(10,1), rand(10,1), rand(10,1)}; % Cell array of 10x1 vectors
% Example output: Corresponding sequences
YTrain = {rand(1,20), rand(1,20), rand(1,20)}; % Cell array of 1x20 sequences
% Define network layers
layers = [
sequenceInputLayer(10) % Input size = 10
fullyConnectedLayer(100)
lstmLayer(100,'OutputMode','sequence')
fullyConnectedLayer(1)
regressionLayer];
% Specify training options
options = trainingOptions('adam', ...
'MaxEpochs', 100, ...
'MiniBatchSize', 16, ...
'SequenceLength', 'longest', ...
'Shuffle', 'every-epoch', ...
'Verbose', false, ...
'Plots', 'training-progress');
% Train the model
net = trainNetwork(XTrain, YTrain, layers, options);
% Predict output sequence for a new input vector
newInput = rand(10,1);
YPred = predict(net, newInput);
This setup allows the network to learn the mapping from static condition vectors to dynamic output sequences. The "sequenceInputLayer" and "lstmLayer" components are particularly well-suited for such temporal prediction tasks.
For further reference, please refer to the following official documentation:
Cheers & Happy Coding!

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by