Main Content

swishLayer

    Description

    A swish activation layer applies the swish function on the layer inputs.

    The swish operation is given by f(x)=x1+ex.

    Creation

    Description

    layer = swishLayer creates a swish layer.

    example

    layer = swishLayer('Name',Name) creates a swish layer and sets the optional Name property using a name-value pair. For example, swishLayer('Name','swish1') creates a swish layer with the name 'swish'.

    Properties

    expand all

    Layer name, specified as a character vector or a string scalar. To include a layer in a layer graph, you must specify a nonempty, unique layer name. If you train a series network with the layer and Name is set to '', then the software automatically assigns a name to the layer at training time.

    Data Types: char | string

    Number of inputs of the layer. This layer accepts a single input only.

    Data Types: double

    Input names of the layer. This layer accepts a single input only.

    Data Types: cell

    Number of outputs of the layer. This layer has a single output only.

    Data Types: double

    Output names of the layer. This layer has a single output only.

    Data Types: cell

    Examples

    collapse all

    Create a swish layer with the name 'swish1'.

    layer = swishLayer('Name','swish1')
    layer = 
      SwishLayer with properties:
    
        Name: 'swish1'
    
      Show all properties
    
    

    Include a swish layer in a Layer array.

    layers = [ ...
        imageInputLayer([28 28 1])
        convolution2dLayer(5,20)
        batchNormalizationLayer
        swishLayer
        maxPooling2dLayer(2,'Stride',2)
        fullyConnectedLayer(10)
        softmaxLayer
        classificationLayer]
    layers = 
      8x1 Layer array with layers:
    
         1   ''   Image Input             28x28x1 images with 'zerocenter' normalization
         2   ''   Convolution             20 5x5 convolutions with stride [1  1] and padding [0  0  0  0]
         3   ''   Batch Normalization     Batch normalization
         4   ''   Swish                   Swish
         5   ''   Max Pooling             2x2 max pooling with stride [2  2] and padding [0  0  0  0]
         6   ''   Fully Connected         10 fully connected layer
         7   ''   Softmax                 softmax
         8   ''   Classification Output   crossentropyex
    

    More About

    expand all

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    GPU Code Generation
    Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

    Introduced in R2021a