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


Python PyTorch GRUCell用法及代碼示例

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

用法:

class torch.nn.quantized.dynamic.GRUCell(input_size, hidden_size, bias=True, dtype=torch.qint8)

門控循環單元 (GRU) 單元

動態量化 GRUCell 模塊,以浮點張量作為輸入和輸出。權重被量化為 8 位。我們采用與torch.nn.GRUCell相同的接口,請參閱https://pytorch.org/docs/stable/nn.html#torch.nn.GRUCell文檔。

例子:

>>> rnn = nn.GRUCell(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.GRUCell。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。