def add_padding(self, name,
            left = 0, right = 0, top = 0, bottom = 0,
            value = 0,
            input_name = 'data', output_name = 'out',
            padding_type = 'constant'):
        """
        Add a padding layer to the model. Kindly refer to NeuralNetwork.proto for details.

        Parameters
        ----------
        name: str
            The name of this layer.
        left: int
            Number of elements to be padded on the left side of the input blob.
        right: int
            Number of elements to be padded on the right side of the input blob.
        top: int
            Number of elements to be padded on the top of the input blob.
        bottom: int
            Number of elements to be padded on the bottom of the input blob.
        value: float
            Value of the elements padded. Used only when padding_type = 'constant'
        input_name: str
            The input blob name of this layer.
        output_name: str
            The output blob name of this layer.
        padding_type: str
            Type of the padding. Can be one of 'constant', 'reflection' or 'replication'

        See Also
        --------
        add_crop, add_convolution, add_pooling
        """
        # Currently only constant padding is supported.
        spec = self.spec
        nn_spec = self.nn_spec

        # Add a new layer
        spec_layer = nn_spec.layers.add()
        spec_layer.name = name
        spec_layer.input.append(input_name)
        spec_layer.output.append(output_name)
        spec_layer_params = spec_layer.padding

        # Set the parameters
        if padding_type == 'constant':
            spec_layer_params.constant.value = value
        elif padding_type == 'reflection':
            spec_layer_params.reflection.MergeFromString(b'')
        elif padding_type == 'replication':
            spec_layer_params.replication.MergeFromString(b'')
        else:
            raise ValueError("Unknown padding_type %s" %(padding_type))


        height_border = spec_layer_params.paddingAmounts.borderAmounts.add()
        height_border.startEdgeSize = top
        height_border.endEdgeSize = bottom
        width_border = spec_layer_params.paddingAmounts.borderAmounts.add()
        width_border.startEdgeSize = left
        width_border.endEdgeSize = right
def add_padding ( self , name , left = 0 , right = 0 , top = 0 , bottom = 0 , value = 0 , input_name = 'data' , output_name = 'out' , padding_type = 'constant' ) : spec = self . spec nn_spec = self . nn_spec spec_layer = nn_spec . layers . add ( ) spec_layer . name = name spec_layer . input . append ( input_name ) spec_layer . output . append ( output_name ) spec_layer_params = spec_layer . padding if padding_type == 'constant' : spec_layer_params . constant . value = value elif padding_type == 'reflection' : spec_layer_params . reflection . MergeFromString ( b'' ) elif padding_type == 'replication' : spec_layer_params . replication . MergeFromString ( b'' ) else : raise ValueError ( "Unknown padding_type %s" % ( padding_type ) ) height_border = spec_layer_params . paddingAmounts . borderAmounts . add ( ) height_border . startEdgeSize = top height_border . endEdgeSize = bottom width_border = spec_layer_params . paddingAmounts . borderAmounts . add ( ) width_border . startEdgeSize = left width_border . endEdgeSize = right
Add a padding layer to the model. Kindly refer to NeuralNetwork.proto for details.

        Parameters
        ----------
        name: str
            The name of this layer.
        left: int
            Number of elements to be padded on the left side of the input blob.
        right: int
            Number of elements to be padded on the right side of the input blob.
        top: int
            Number of elements to be padded on the top of the input blob.
        bottom: int
            Number of elements to be padded on the bottom of the input blob.
        value: float
            Value of the elements padded. Used only when padding_type = 'constant'
        input_name: str
            The input blob name of this layer.
        output_name: str
            The output blob name of this layer.
        padding_type: str
            Type of the padding. Can be one of 'constant', 'reflection' or 'replication'

        See Also
        --------
        add_crop, add_convolution, add_pooling