function layer = sigmoidLayer(varargin)
% sigmoidLayer   Sigmoid layer
%
%   layer = sigmoidLayer creates a sigmoid layer. This type of
%   layer applies the sigmoid function to its input such that the  
%   output is bounded between 0 and 1.
%
%   layer = sigmoidLayer('Name', name) additionally specifies the layer name.
%
%   Example:
%       Create a sigmoid layer.
%
%       layer = sigmoidLayer;
%
%   See also nnet.cnn.layer.SigmoidLayer, softmaxLayer, fullyConnectedLayer.
%
%   <a href="matlab:helpview('deeplearning','list_of_layers')">List of Deep Learning Layers</a>

%   Copyright 2019 The MathWorks, Inc.

% Parse the input arguments.
inputArguments = iParseInputArguments(varargin{:});

layer = nnet.cnn.layer.SigmoidLayer(inputArguments.Name);

end

function inputArguments = iParseInputArguments(varargin)
parser = iCreateParser();
parser.parse(varargin{:});
inputArguments = iConvertToCanonicalForm(parser);
end

function p = iCreateParser()
p = inputParser;
defaultName = '';
addParameter(p, 'Name', defaultName, @iAssertValidLayerName);
end

function iAssertValidLayerName(name)
nnet.internal.cnn.layer.paramvalidation.validateLayerName(name);
end

function inputArguments = iConvertToCanonicalForm(p)
inputArguments = struct;
inputArguments.Name = char(p.Results.Name); % make sure strings get converted to char vectors
end
