mindspore/docs/api/api_python/ops/mindspore.ops.LSTM.rst

43 lines
2.5 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.LSTM
===================
.. py:class:: mindspore.ops.LSTM(input_size, hidden_size, num_layers, has_bias, bidirectional, dropout, proj_size=0)
对输入执行长短期记忆LSTM网络。
有关详细信息,请参见 :class:`mindspore.nn.LSTM`
参数:
- **input_size** (int) - 输入的大小。
- **hidden_size** (int) - 隐藏状态大小。
- **num_layers** (int) - LSTM的网络层数当前CPU只支持 `1`
- **has_bias** (bool) - Cell是否有偏置 `b_ih``b_hh` 当前CPU只支持 `False`
- **bidirectional** (bool) - 是否为双向LSTM当前CPU只支持 `False`
- **dropout** (float) - 指的是除第一层外每层输入时的dropout概率。dropout的范围为[0.0, 1.0]。
- **proj_size** (int) - 如果大于0则会使用对应大小的投影当前只支持CPU后端。默认值: ``0``
输入:
- **input** (Tensor) - shape为 :math:`(seq\_len, batch\_size, input\_size)`:math:`(batch\_size, seq\_len, input\_size)` 的Tensor。
- **h** (tuple) - shape为 :math:`(num\_directions * num\_layers, batch\_size, real\_hidden\_size)` 的Tensor。
- **c** (tuple) - shape为 :math:`(num\_directions * num\_layers, batch\_size, hidden\_size)` 的Tensor。
- **w** (Tensor) - 权重。
如果 :math:`proj\_size > 0` , :math:`real\_hidden\_size = proj\_size` ,否则
:math:`real\_hidden\_size = hidden\_size`
输出:
tupletuple包含 `(output, h\_n, c\_n, reserve, state)`
- **output** (Tensor) - shape为 :math:`(seq\_len, batch\_size, num\_directions * real\_hidden\_size)` 的Tensor。
- **h_n** (Tensor) - shape为 :math:`(num\_directions * num\_layers, batch\_size, real\_hidden\_size)` 的Tensor。
- **c_n** (Tensor) - shape为 :math:`(num\_directions * num\_layers, batch\_size, hidden\_size)` 的Tensor。
- **reserve** (Tensor) - shape为 :math:`(r, 1)`
- **state** (Tensor) - 使用随机数生成状态及其shape为 :math:`(s, 1)`
异常:
- **TypeError** - 如果 `input_size` `hidden_size``num_layers` 不是int。
- **TypeError** - 如果 `has_bias``bidirectional` 不是bool。
- **TypeError** - 如果 `dropout` 不是float。
- **ValueError** - 如果 `dropout` 不在范围[0.0, 1.0]内。
- **ValueError** - 如果 `proj_size` 不在范围[0, `hidden_size`)内。