深度学习与PyTorch入门实战 - 18.1 激活函数梯度4564e-25, 3.3382e-15, 1.4945e-05, 9.9999e-01, 1.0000e+00, 1.0000e+00, 1.0000e+00, 1.0000e+00]) ## Tanh $$ f(x)=\tanh(x)=\frac{(e^{x}-e^{-x})}{(e^{x}+e^{-x})} $$ $$ =2sigmoid(2x)-1 $$ =\frac{(e^{x}+e^{-x})(e^{x}+e^{-x})-(e^{x}-e^{-x})(e^{x}-e^{-x})}{(e^{x}+e^{-x})^{2}}\\ &=1-\frac{(e^{x}-e^{-x})^{2}}{(e^{x}+e^{-x})^{2}}=1-\tanh^{2}(x)\\ \end{aligned} $$ torch.tanh ☀️ ☀️ ☀️ ☁️ In [9]: a=torch.linspace(-1,1,10) In [10]: torch.tanh(a) Out $$ 10 $$ : tensor([-0.7616, -0.6514, -0.5047, -0.3215, -0.1107, 0.1107, 0.3215, 0.5047, 0.6514, 0.7616]) ## Rectified Linear Unit0 码力 | 14 页 | 724.00 KB | 2 年前3
机器学习课程-温州大学-11深度学习-序列模型np.append(state, X[i]) before_activation = np.dot(state, w_cell_state) + b_cell state = np.tanh(before_activation) final_output = np.dot(state, w_output) + b_output print("状态值_%i:" t\rangle}=\sigma(W_{u}[a^{\langle t-1\rangle},x^{\langle t\rangle}]+b_{u})\\&\tilde{c}^{\{t\}}=\tanh(W_{C}[a^{\langle t-1\rangle},x^{\langle t\rangle}]+b_{C})\\&c^{\langle t\rangle}=\Gamma_{f}^{\langle t-1\rangle},x^{\langle t\rangle}]+b_{o})\\&a^{\langle t\rangle}=\Gamma_{o}^{\langle t\rangle}\circ\tanh(c^{\langle t\rangle})\\ \end{aligned} $$ lstm=nn.LSTM(input size=10,hidden size=20,num layers=2)0 码力 | 29 页 | 1.68 MB | 2 年前3
深度学习与PyTorch入门实战 - 51. LSTM原理values we’ll update. $$ i_{t}=\sigma\left(W_{i}\cdot[h_{t-1},x_{t}]\right.+\left.b_{i}\right) $$ a tanh layer creates a vector of new candidate values, that could be added to the state. $$ \tilde{C}_{t}=\mathrm{t o_{t}=\sigma\left(W_{o}\left[h_{t-1},x_{t}\right]+b_{o}\right) $$ Then, we put the cell state through tanh (to push the values to be between -1 and 1) and multiply it by the output of the sigmoid gate, so {(t)}\\\mathbf{o}^{(t)}\\\tilde{\mathcal{C}}\end{pmatrix}=\begin{pmatrix}\sigma\\\sigma\\\sigma\\\tanh\end{pmatrix}\mathbf{W}\begin{pmatrix}\mathbf{x}^{(t)}\\\mathbf{h}^{(t-1)}\end{pmatrix} $$ $$ \0 码力 | 16 页 | 1.53 MB | 2 年前3
机器学习课程-温州大学-04深度学习-深层神经网络### 3. 激活函数 $$ \begin{aligned}&tanh 函数 \\&a=tanh(z)=\frac{e^{z}-e^{-z}}{e^{z}+e^{-z}}\\&\frac{d}{dz}g(z)=1-\left(tanh(z)\right)^{2}\end{aligned} $$ tanh函数是sigmoid的向下平移和伸缩后的结果。对它进行了变形后,穿过了 $ (0,0) $ 点,并且值域介于+1和-1之间。 tanh函数是总体上都优于sigmoid函数的激活函数。 ### 3. 激活函数 ## ReLu函数 $$ a=max(0,z) $$ 在输入是负值的情况下,它会输出0,那么神经元就不会被激活。这意味着同一时间只有部分神经元会被激活,从而使得网络很稀疏,进而对计算来说是非常有效率的。  REVERSE() RIGHT() ROUND() RPAD() SIGN() SIN() SINH() SQRT() SUBSTRING() TAN() TANH() TRIM() TRUNC() UPPER() UUID_TO_CHAR() .B.WeHhHne fHyHKiiu (UDF) abs acos addDay addHour rpad rtrim sdow sign sin sinh sqrt srand sright string2blob strlen substr substrlen tan tanh truncate, i64truncate Приложение А: Примечания Набор символов NONE воспринимается «как есть» (“as ROUND RPAD SCALAR_ARRAY SEQUENCE SIGN SIN SINH SKIP SOURCE SPACE SQRT SUBSTRING TAN TANH TEMPORARY TRUNC TWO_PHASE WEEK UPDATING UUID_TO_CHAR Удалено начиная с InterBase 6 Более не0 码力 | 364 页 | 1.45 MB | 2 年前3
【PyTorch深度学习-龙龙老师】-测试版202112参数,像 Sigmoid 层一样将 LeakyReLU 层放置在网络的合适位置。 #### 6.4.4 Tanh Tanh 函数能够将 $ x \in R $ 的输入 “压缩” 到 $ (-1,1) $ 区间,定义为: $$ \begin{aligned}&\tanh(x)=\frac{(\mathrm{e}^{x}-\mathrm{e}^{-x})}{(\mathrm{e 可以看到 tanh 激活函数可通过 Sigmoid 函数缩放平移后实现,函数曲线如图 6.11 所示。  图 6.11 tanh 函数曲线 在 TensorFlow 中,可以通过 tf.nn.tanh 实现 tanh 函数,代码如下: torch.tanh(x) # 通过 Tanh 激活函数 print(out) Out $$ 11 $$ : tensor([-1.0000, -0.9998, -0.9975, -0.9640, -0.5828, 0.5828, 0.9640, 0.9975, 0.9998, 1.0000]) 可以看到向量元素值的范围被映射到 $ (-1,1) $ 之间。注意,这里调用的 tanh 位于 torch0 码力 | 439 页 | 29.91 MB | 2 年前3
Keras: 基于 Python 的深度学习库.... 144 10.2.4 softplus ..... 144 10.2.5 softsign ..... 144 10.2.6 relu ..... 144 10.2.7 tanh ..... 144 10.2.8 sigmoid ..... 144 10.2.9 hard_sigmoid ..... 144 10.2.10 linear ..... 144 RNN(cells) y = layer(x) #### 5.6.2 SimpleRNN [source] keras.layers.SimpleRNN(units, activation='tanh', use_bias=True, kernel_initializer='glorot_uniform', recurrent 以加速 RNN,但它往往会占用更多的内存。展开只适用于短序列。 #### 5.6.3 GRU [source] keras.layers.GRU(units, activation='tanh', recurrent_activation='hard_sigmoid', use_bias=True, kernel_initializer='glorot_uniform'0 码力 | 257 页 | 1.19 MB | 2 年前3
动手学深度学习 v2.0figsize=(5, 2.5)) ## tanh函数 与sigmoid函数类似,tanh(双曲正切)函数也能将其输入压缩转换到区间 $ (-1,1) $ 上。tanh函数的公式如下: $$ \operatorname{tanh}(x)=\frac{1-\exp(-2x)}{1+\exp(-2x)}. $$ 下面我们绘制tanh函数。注意,当输入在0附近时,tanh函数接近线性变换。函数的形状类似 函数,不同的是tanh函数关于坐标系原点中心对称。 y = torch.tanh(x) d2l.plot(x.detach(), y.detach(), 'x', 'tanh(x)', figsize=(5, 2.5)) tanh函数的导数是: $$ \frac{d}{dx}\tanh(x)=1-\tanh^{2}(x). $$ tanh函数的导数图像如 tanh函数的导数图像如下所示。当输入接近0时,tanh函数的导数接近最大值1。与我们在sigmoid函数图像中看到的类似,输入在任一方向上越远离0点,导数越接近0。 # 清除以前的梯度 x.grad.data.zero() (continues on next page) y.backward(torch.ones_like(x), retain_graph=True) d2l.plot(x.detach(), x0 码力 | 797 页 | 29.45 MB | 2 年前3
《TensorFlow 快速入门与实战》5-实战TensorFlow手写体数字识别激活函数(Activation Function) 为了实现神经网络的非线性建模能力,解决一些线性不可分的问题,我们通常使用激活函数来引入非线性因素。激活函数都采用非线性函数,常用的有Sigmoid、tanh、ReLU等。 Sigmoid $$ \sigma(x)=\frac{1}{1+e^{-x}} $$   tanh tanh(x)  Maxout0 码力 | 38 页 | 1.82 MB | 2 年前3
深度学习与PyTorch入门实战 - 47. RNN原理-1},x_{t})\\&\downarrow\\h_{t}&=\tanh(W_{hh}h_{t-1}+W_{xh}x_{t})\\y_{t}&=W_{hy}h_{t}\end{aligned} $$ How To Train? $$ \begin{aligned}h_{t}=tanh(W_{I}x_{t}+W_{R}h_{t-1})\\y_{t}=W_{O}h_{t}\end{aligned}0 码力 | 12 页 | 705.66 KB | 2 年前3
共 207 条
- 1
- 2
- 3
- 4
- 5
- 6
- 21













