필터 지우기
필터 지우기

Troubles with Experiment Manager Setup for LSTM regression

조회 수: 6 (최근 30일)
massimo giannini
massimo giannini 2024년 8월 10일
댓글: massimo giannini 2024년 8월 12일
I need help!
I am managing Experiment Manager with a very simple exercise. I use data stocks for one-step ahead of the close price with a simple LSTM net. The net works well with trainnest(XTest,YTest,layers,options). I want to calibrate the Epochs parameters with Experiment Manager. I followed any suggestions and tutorials on the web but I can not do it. Xtest is an array with 6 cols (open, close, volum etc.) and 2401 (time steps) rows for a given stock. The reponse is a single 2401 vector containing one-time shifted of the close price. As said. I have no problem with trainnet and the net performs well.
I put data, layers and options in the script for Experiment Manager. Here is my code:
function [XTrain_N,YTrain_N,layers,options] = Experiment1_setup1(params)
load dati_net.mat XTrain_N YTrain_N
num_features = 6;
num_responses = 1;
num_hidden_units = 350;
layers = [
featureInputLayer(6);
lstmLayer(num_hidden_units, 'OutputMode','last')
fullyConnectedLayer(num_responses)
];
%Training Options
options = trainingOptions("adam", ...
MaxEpochs=params.MaxEpochs, ...
SequencePaddingDirection="left",...
InitialLearnRate=0.001,...
Shuffle="every-epoch", ...
ValidationFrequency=50, ...
GradientThreshold=.93, ...
L2Regularization=0.00001, ...
Verbose=false, ...
Metrics="rmse", ...
Plots="training-progress");
end
But when I run the experiment I always get:
The following errors occurred while running the experiment:
Errors occurred while validating the setup function: Caused by: Invalid output arguments from setup function. Third-from-last output of setup function must be a layer array or dlnetwork object, but a value of type 'double' was detected.
I tried dozens of trials but I am able to escape the problem. I attach also my data
Thanks in Advance!
  댓글 수: 2
dpb
dpb 2024년 8월 10일
The function as shown doesn't return any of the return variables...
massimo giannini
massimo giannini 2024년 8월 11일
Ok so how can I fix it?

댓글을 달려면 로그인하십시오.

채택된 답변

Jaimin
Jaimin 2024년 8월 12일
편집: Jaimin 2024년 8월 12일
According to the issue description, you are able to train your model using thetrainnetfunction. However, when attempting to tune the epoch hyperparameter value using MATLAB's Experiment Manager app, you encounter an error.
One workaround I found is to usetrainNetworkinstead oftrainnetin Experiment Manager. To do this
  1. Click on "New" -> "Project" -> "Blank Project"
  2. Select the 'Built-In Training' experiment from the 'Blank Built-In trainNetwork Experiment' as shown in the image below.
  3. After selecting that, configure the parameters as shown in the image below.
  4. Set all other parameters according to requirements.
Additionally, there is a modification in"Experiment1_setup1". Here is the updated code.
function [XTrain_N, YTrain_N, layers, options] = SequenceRegressionExperiment_setup2(params)
load dati_net.mat XTrain_N YTrain_N
num_features = 6;
num_responses = 1;
num_hidden_units = 350;
layers = [
featureInputLayer(6);
lstmLayer(num_hidden_units, 'OutputMode','last')
fullyConnectedLayer(num_responses)
regressionLayer
];
%Training Options
options = trainingOptions("adam", ...
MaxEpochs=params.MaxEpochs, ...
SequencePaddingDirection="left",...
InitialLearnRate=0.001,...
Shuffle="every-epoch", ...
ValidationFrequency=50, ...
GradientThreshold=.93, ...
L2Regularization=0.00001, ...
Verbose=false, ...
Plots="training-progress");
end
I have attached some resources that will be helpful to you.
I hope this helps!
  댓글 수: 1
massimo giannini
massimo giannini 2024년 8월 12일
Great! Thank you!!
I found a second working alternative yesterday by "try and guess". I converted XTrain_N YTrain_N to a datastore:
load dati_net.mat XTrain_N YTrain_N
adsXTrain = arrayDatastore(XTrain_N);
adsYTrain = arrayDatastore(YTrain_N);
cdsTrain = combine(adsXTrain,adsYTrain);
, erased Metrics from the options and used this string for the function:
function [cdsTrain,layers,lossFcn,options] = Experiment1_setup1(params)
lossFcn="mse";
and now Experiment Manager works.
Anyway thanks for your valuable help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by