You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.LSTMCell.rst 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. mindspore.nn.LSTMCell
  2. ======================
  3. .. py:class:: mindspore.nn.LSTMCell(*args, **kwargs)
  4. 长短期记忆网络单元(LSTMCell)。
  5. 公式如下:
  6. .. math::
  7. \begin{array}{ll} \\
  8. i_t = \sigma(W_{ix} x_t + b_{ix} + W_{ih} h_{(t-1)} + b_{ih}) \\
  9. f_t = \sigma(W_{fx} x_t + b_{fx} + W_{fh} h_{(t-1)} + b_{fh}) \\
  10. \tilde{c}_t = \tanh(W_{cx} x_t + b_{cx} + W_{ch} h_{(t-1)} + b_{ch}) \\
  11. o_t = \sigma(W_{ox} x_t + b_{ox} + W_{oh} h_{(t-1)} + b_{oh}) \\
  12. c_t = f_t * c_{(t-1)} + i_t * \tilde{c}_t \\
  13. h_t = o_t * \tanh(c_t) \\
  14. \end{array}
  15. 其中 :math:`\sigma` 是sigmoid函数, :math:`*` 是乘积。 :math:`W,b` 是公式中输出和输入之间的可学习权重。例如,:math:`W_{ix}, b_{ix}` 是用于从输入 :math:`x` 转换为 :math:`i` 的权重和偏置。详见论文 `LONG SHORT-TERM MEMORY <https://www.bioinf.jku.at/publications/older/2604.pdf>`_ 和 `Long Short-Term Memory Recurrent Neural Network Architectures for Large Scale Acoustic Modeling <https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/43905.pdf>`_ 。
  16. **参数:**
  17. - **input_size** (int) - 输入的大小。
  18. - **hidden_size** (int)- 隐藏状态大小。
  19. - **has_bias** (bool) - cell是否有偏置 `b_ih` 和 `b_hh` 。默认值:True。
  20. **输入:**
  21. - **x** (Tensor) - shape为(batch_size, `input_size`)的Tensor。
  22. - **hx** (tuple) - 两个Tensor(h_0,c_0)的元组,其数据类型为mindspore.float32,shape为(batch_size, `hidden_size`)。 `hx` 的数据类型必须与 `x` 相同。
  23. **输出:**
  24. - **hx'** (Tensor) - 两个Tensor(h', c')的元组,其shape为(batch_size, `hidden_size`)。
  25. **异常:**
  26. - **TypeError** - `input_size`, `hidden_size` 不是整数。
  27. - **TypeError** - `has_bias` 不是bool。