第10章現代のリカレントニューラルネットワーク
10.4.2. Concise Implementation10.4.2 簡潔な実装
Using the high-level APIs, we can implement bidirectional RNNs more concisely. Here we take a GRU model as an example.
英語のヒント
高水準APIを使えば、双方向RNNをもっと簡潔に実装できる。ここではGRUモデルを例にとる。
class BiGRU(d2l.RNN):
def __init__(self, num_inputs, num_hiddens):
d2l.Module.__init__(self)
self.save_hyperparameters()
self.rnn = nn.GRU(num_inputs, num_hiddens, bidirectional=True)
self.num_hiddens *= 2