MATLAB Answers

0

LSTM time series hyperparameter optimization using bayesian optimization

Asked by anurag kulshrestha on 22 Apr 2019
Latest activity Answered by Don Mathis on 10 May 2019
I am working with time series regression problem. I want to optimize the hyperparamters of LSTM using bayesian optimization. I have 3 input variables and 1 output variable.
I want to optimize the number of hidden layers, number of hidden units, mini batch size, L2 regularization and initial learning rate . Code is given below:
numFeatures = 3;
numHiddenUnits = 120;
numResponses = 1;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(numResponses)
regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'InitialLearnRate',optVars.InitialLearnRate, ...
'Momentum',optVars.Momentum, ...
'GradientThreshold',1, ...
'Shuffle','never', ...
'L2Regularization',optVars.L2Regularization, ...
'Plots','training-progress',...
'Verbose',0);
net = trainNetwork(XTrain,YTrain,layers,options);
YPredicted = predict(net,Xval, 'MiniBatchSize',1);
valError = 1 - mean(YPredicted == Yval);
Thanks in advance.

  0 Comments

Sign in to comment.

1 Answer

Answer by Don Mathis on 10 May 2019

Here's an example using a convolutional network instead of an LSTM network. Your LSTM case should look very similar: https://www.mathworks.com/help/deeplearning/examples/deep-learning-using-bayesian-optimization.html

  0 Comments

Sign in to comment.