Main Content

tanhLayer

Hyperbolic tangent (tanh) layer

Description

A hyperbolic tangent (tanh) activation layer applies the tanh function on the layer inputs.

Creation

Description

layer= tanhLayercreates a hyperbolic tangent layer.

example

layer= tanhLayer('Name',Name)additionally specifies the optionalNameproperty. For example,tanhLayer('Name','tanh1')creates a tanh layer with the name'tanh1'.

Properties

expand all

Layer name, specified as a character vector or a string scalar. ForLayerarray input, thetrainNetwork,assembleNetwork,layerGraph, anddlnetworkfunctions automatically assign names to layers withNameset to''.

Data Types:char|string

This property is read-only.

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

Data Types:double

This property is read-only.

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

Data Types:cell

This property is read-only.

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

Data Types:double

This property is read-only.

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

Data Types:cell

Examples

collapse all

Create a hyperbolic tangent (tanh) layer with the name'tanh1'.

layer = tanhLayer('Name','tanh1')
layer = TanhLayer with properties: Name: 'tanh1' Learnable Parameters No properties. State Parameters No properties. Show all properties

Include a tanh layer in aLayerarray.

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

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 R2019a