|
function layers = EEGNetModel(in_chans, n_classes, varargin) |
|
|
|
|
|
|
|
p = inputParser; |
|
addRequired(p, 'in_chans'); |
|
addRequired(p, 'n_classes'); |
|
addRequired(p, 'input_window_samples'); |
|
addParameter(p, 'pool_mode', 'mean'); |
|
addParameter(p, 'F1', 8); |
|
addParameter(p, 'D', 2); |
|
addParameter(p, 'F2', 16); |
|
addParameter(p, 'kernel_length', 64); |
|
addParameter(p, 'third_kernel_size', [8, 4]); |
|
addParameter(p, 'drop_prob', 0.25); |
|
parse(p, in_chans, n_classes, varargin{:}); |
|
|
|
|
|
params = p.Results; |
|
|
|
|
|
|
|
|
|
layers = [ |
|
imageInputLayer([params.in_chans, params.input_window_samples, 1], 'Normalization', 'none') |
|
convolution2dLayer([1, params.kernel_length], params.F1, 'Stride', [1, 1], 'Padding',[0, floor(params.kernel_length / 2)]) |
|
batchNormalizationLayer() |
|
convolution2dLayer([params.in_chans, 1], params.F1*params.D, 'Stride', [1, 1], 'Padding', [0, 0]) |
|
batchNormalizationLayer() |
|
reluLayer() |
|
averagePooling2dLayer([1, 4], 'Stride', [1, 4]) |
|
dropoutLayer(params.drop_prob) |
|
]; |
|
|
|
|
|
layers = [ |
|
layers |
|
convolution2dLayer([1, 16], params.F1*params.D, 'Stride', [1, 1], 'Padding', [0, 8]) |
|
convolution2dLayer([1, 1], params.F2, 'Stride', [1, 1], 'Padding', [0, 0]) |
|
batchNormalizationLayer() |
|
reluLayer() |
|
averagePooling2dLayer([1, 8], 'Stride', [1, 8]) |
|
dropoutLayer(params.drop_prob) |
|
]; |
|
|
|
|
|
layers = [ |
|
layers |
|
convolution2dLayer([1, 23], params.n_classes) |
|
softmaxLayer() |
|
classificationLayer() |
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|