當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python PyTorch RNNCell用法及代碼示例

本文簡要介紹python語言中 torch.nn.quantized.dynamic.RNNCell 的用法。

用法:

class torch.nn.quantized.dynamic.RNNCell(input_size, hidden_size, bias=True, nonlinearity='tanh', dtype=torch.qint8)

具有 tanh 或 ReLU 非線性的 Elman RNN 單元。以浮點張量作為輸入和輸出的動態量化 RNNCell 模塊。權重被量化為 8 位。我們采用與torch.nn.RNNCell相同的接口,請參閱https://pytorch.org/docs/stable/nn.html#torch.nn.RNNCell文檔。

例子:

>>> rnn = nn.RNNCell(10, 20)
>>> input = torch.randn(6, 3, 10)
>>> hx = torch.randn(3, 20)
>>> output = []
>>> for i in range(6):
        hx = rnn(input[i], hx)
        output.append(hx)

相關用法


注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.nn.quantized.dynamic.RNNCell。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。