Main Content

dlhdl.layer.sliceLayer

Slice layer

Since R2024a

    Description

    Use sliceLayer objects to divide the input to the layer into an equal number of groups along the channel dimension of the image.

    Creation

    Description

    layer = dlhdl.layer.sliceLayer creates a slice layer.

    layer = dlhdl.layer.sliceLayer('Name'=Name,Name=Value) creates a slice layer with the name Name, and sets additional Groups, and GroupID properties using one or more name-value pair arguments.

    example

    Properties

    expand all

    This property is read-only.

    Number of groups to split input features into, specified as a positive integer. The value of this property must be two.

    Example: 2

    This property is read-only.

    ID of group to pass as output, specified as a positive integer. The value of this property must be two.

    Example: 2

    Layer

    Layer name, specified as a character vector or string scalar. For Layer array input, the trainnet and dlnetwork functions automatically assign names to layers with the name "".

    The sliceLayer object stores this property as a character vector.

    Data Types: char | string

    This property is read-only.

    Number of inputs to the layer, returned as 1. This layer accepts a single input only.

    Data Types: double

    This property is read-only.

    Input names, returned as {'in'}. This layer accepts a single input only.

    Data Types: cell

    This property is read-only.

    Number of outputs from the layer, returned as 1. This layer has a single output only.

    Data Types: double

    This property is read-only.

    Output names, returned as {'out'}. This layer has a single output only.

    Data Types: cell

    Examples

    collapse all

    Create a slice layer with the name "slice1".

    layer = dlhdl.layer.sliceLayer(Name="slice1")
    layer = 
      sliceLayer with properties:
    
           Name: 'slice1'
         Groups: 2
        GroupId: 2
       Learnable Parameters
        No properties.
       State Parameters
        No properties.
      Show all properties

    Include the slice layer in a Layer array.

     iamgeSize = [20 20 16];
    layers = [
                    imageInputLayer(imageSize,"Name","imageinput","Normalization","none")
                    convolution2dLayer(3,16,"Padding","same")
                    dlhdl.layer.sliceLayer(Name="slice",Groups=2,GroupID=2)
                    maxPooling2dLayer(3,'Padding','same','Name','pool')]
    
    layers = 
      4×1 Layer array with layers:
    
         1   'imageinput'   Image Input              20×20×16 images
         2   ''             2-D Convolution          16 3×3 convolutions with stride [1  1] and padding 'same'
         3   'slice'        dlhdl.layer.sliceLayer   dlhdl.layer.sliceLayer
         4   'pool'         2-D Max Pooling          3×3 max pooling with stride [1  1] and padding 'same'

    Algorithms

    expand all

    Version History

    Introduced in R2024a