LSTM¶
- class torch.ao.nn.quantizable.LSTM(input_size, hidden_size, num_layers=1, bias=True, batch_first=False, dropout=0.0, bidirectional=False, device=None, dtype=None)[源代码]¶
一个可量化的长短期记忆(LSTM)。
有关描述和参数类型,请参阅
LSTM- Variables
层 – _LSTMLayer 的实例
注意
要访问权重和偏差,您需要按层访问它们。 请参见下面的示例。
示例:
>>> import torch.ao.nn.quantizable as nnqa >>> rnn = nnqa.LSTM(10, 20, 2) >>> input = torch.randn(5, 3, 10) >>> h0 = torch.randn(2, 3, 20) >>> c0 = torch.randn(2, 3, 20) >>> output, (hn, cn) = rnn(input, (h0, c0)) >>> # 获取权重: >>> print(rnn.layers[0].weight_ih) tensor([[...]]) >>> print(rnn.layers[0].weight_hh) AssertionError: 在非双向层中没有反向路径