AI术语词典

A comprehensive multilingual AI terminology dictionary

Definition

门控循环单元(GRU)是一种专门的循环神经网络(RNN)单元,旨在捕捉序列数据中的长期依赖关系。它简化了长短期记忆(LSTM)架构。

Summary

一种使用门控机制控制信息流动的循环神经网络架构,作为LSTM的简化替代方案。

Key Concepts

Use Cases

Code Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import torch.nn as nn

# Define a simple GRU layer
gru = nn.GRU(input_size=10, hidden_size=20, num_layers=1)

# Example input: (seq_len, batch, input_size)
input_data = torch.randn(5, 3, 10)
hidden_state = None

output, hidden = gru(input_data, hidden_state)