classdef reflectionPad2dLayer < nnet.layer.Layer
% 2D Reflection padding layer for convolutional neural networks
%
%   layer = reflectionPad2dLayer(padding,name) creates a reflection padding
%   layer. Padding is a numeric scalar that specifies the amount of padding
%   applied to the convolutional feature map. An equal amount of padding is
%   applied to the x and the y dimensions. Name specifies the name of the
%   layer.
    properties
        Padding
    end
    
    methods
        function layer = reflectionPad2dLayer(padding, name)
            % Set layer name.
            layer.Name = name;
            
            % Set layer description.
            layer.Description = strcat("ReflectionPad2d Layer with padding ",int2str(padding));
            
            % Padding by which the image is to be padded
            layer.Padding = padding;
        end
        
        function Z = predict(layer, X)
            % Z = predict(layer, X) forwards the input data X through the
            % layer and outputs the result Z.
            Z = padarray(X, [layer.Padding layer.Padding], "symmetric");
        end
    end
end