43 lines
2.5 KiB
ReStructuredText
43 lines
2.5 KiB
ReStructuredText
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` 。
|
||
|
||
输出:
|
||
tuple,tuple包含 `(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`)内。
|