当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。