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

38 lines
2.0 KiB
ReStructuredText
Raw Normal View History

mindspore.ops.LSTM
===================
2022-11-19 10:12:44 +08:00
.. py:class:: mindspore.ops.LSTM(input_size, hidden_size, num_layers, has_bias, bidirectional, dropout)
2022-11-01 19:52:13 +08:00
对输入执行长短期记忆LSTM网络。
有关详细信息,请参见 :class:`mindspore.nn.LSTM`
参数:
- **input_size** (int) - 输入的大小。
- **hidden_size** (int) - 隐藏状态大小。
- **num_layers** (int) - LSTM的网络层数。
- **has_bias** (bool) - Cell是否有偏置 `b_ih``b_hh`
- **bidirectional** (bool) - 是否为双向LSTM。
2022-11-19 10:12:44 +08:00
- **dropout** (float) - 指的是除第一层外每层输入时的dropout概率。dropout的范围为[0.0, 1.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, hidden\_size)` 的Tensor。
- **c** (tuple) - shape为 :math:`(num\_directions * num\_layers, batch\_size, hidden\_size)` 的Tensor。
- **w** (Tensor) - 权重。
输出:
tupletuple包含( `output` , `h\_n` , `c\_n` , `reserve` , `state` )。
- **output** (Tensor) - shape为 :math:`(seq\_len, batch\_size, num\_directions * hidden\_size)` 的Tensor。
- **h_n** (Tensor) - shape为 :math:`(num\_directions * num\_layers, batch\_size, 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]内。