function options = helperModClassTrainingOptions(maxEpochs,miniBatchSize,...
  trainingSize,rxValidFrames,rxValidLabels)
%helperModClassTrainingOptions Modulation classification training options
%   OPT = helperModClassTrainingOptions(MAXE,MINIBATCH,NTRAIN,Y,YLABEL)
%   returns the training options, OPT, for the modulation classification
%   CNN, where MAXE is the maximum number of epochs, MINIBATCH is the mini
%   batch size, NTRAIN is the number of training frames, Y is the
%   validation frames and YLABEL is the labels.
%
%   This function configures the training options to use an SGDM solver.
%   By default, the 'ExecutionEnvironment' property is set to 'auto', where
%   the trainNetwork function uses a GPU if one is available or uses the
%   CPU, if not. To use the GPU, you must have a Parallel Computing Toolbox
%   license. Set the initial learning rate to 2e-2. Reduce the learning
%   rate by a factor of 10 every 9 epochs. Set 'Plots' to
%   'training-progress' to plot the training progress.
%   
%   See also ModulationClassificationWithDeepLearningExample.

%   Copyright 2019 The MathWorks, Inc.

validationFrequency = floor(trainingSize/miniBatchSize);
options = trainingOptions('sgdm', ...
  'InitialLearnRate',2e-2, ...
  'MaxEpochs',maxEpochs, ...
  'MiniBatchSize',miniBatchSize, ...
  'Shuffle','every-epoch', ...
  'Plots','training-progress', ...
  'Verbose',false, ...
  'ValidationData',{rxValidFrames,rxValidLabels}, ...
  'ValidationFrequency',validationFrequency, ...
  'LearnRateSchedule', 'piecewise', ...
  'LearnRateDropPeriod', 9, ...
  'LearnRateDropFactor', 0.1);
