tanhLayer
双曲正切 (tanh) 层
说明
双曲正切 (tanh) 激活层对层输入应用 tanh 函数。
创建对象
属性
NumInputs
— 输入的数目
1
(默认)
此 属性 为只读。
层的输入数,返回为 1
。此层只接受一个输入。
数据类型: double
InputNames
— 输入名称
{'in'}
(默认)
此 属性 为只读。
输入名称,返回为 {'in'}
。此层只接受一个输入。
数据类型: cell
NumOutputs
— 输出的数目
1
(默认)
此 属性 为只读。
层的输出数,返回为 1
。此层只有一个输出。
数据类型: double
OutputNames
— 输出名称
{'out'}
(默认)
此 属性 为只读。
输出名称,返回为 {'out'}
。此层只有一个输出。
数据类型: cell
示例
创建双曲正切层
创建一个名为 'tanh1'
的双曲正切 (tanh) 层。
layer = tanhLayer('Name','tanh1')
layer = TanhLayer with properties: Name: 'tanh1' Learnable Parameters No properties. State Parameters No properties. Use properties method to see a list of all properties.
在 Layer
数组中包括一个 tanh 层。
layers = [
imageInputLayer([28 28 1])
convolution2dLayer(3,16)
batchNormalizationLayer
tanhLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32)
batchNormalizationLayer
tanhLayer
fullyConnectedLayer(10)
softmaxLayer]
layers = 10x1 Layer array with layers: 1 '' Image Input 28x28x1 images with 'zerocenter' normalization 2 '' 2-D Convolution 16 3x3 convolutions with stride [1 1] and padding [0 0 0 0] 3 '' Batch Normalization Batch normalization 4 '' Tanh Hyperbolic tangent 5 '' 2-D Max Pooling 2x2 max pooling with stride [2 2] and padding [0 0 0 0] 6 '' 2-D 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
算法
层输入和输出格式
层数组或层图中的层将数据作为格式化的 dlarray
对象传递给后续层。dlarray
对象的格式是字符串,其中每个字符描述数据的对应维度。格式由以下一个或多个字符组成:
"S"
- 空间"C"
- 通道"B"
- 批量"T"
- 时间"U"
- 未指定
例如,以四维数组表示的二维图像数据(其中前两个维度对应于图像的空间维度,第三个维度对应于图像的通道,第四个维度对应于批量维度)的格式可以描述为 "SSCB"
(空间、空间、通道、批量)。
TanhLayer
对象应用按元素运算并支持任何格式的输入数据。层不会添加或删除任何维度,因此它输出的数据与其输入的格式相同。
复数
TanhLayer
对象支持复数值输入和输出。 (自 R2024a 起)该层对复数值输入应用与对实数值输入相同的底层运算,并在适用的情况下输出复数值数据。
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
GPU 代码生成
使用 GPU Coder™ 为 NVIDIA® GPU 生成 CUDA® 代码。
版本历史记录
在 R2019a 中推出R2024a: 支持复数值输入和输出
TanhLayer
对象支持复数值输入和输出。该层对复数值输入应用与对实数值输入相同的底层运算,并在适用的情况下输出复数值数据。
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)